2016-04-05 87 views
0

FID:https://jsfiddle.net/k13sazuz/jQuery的:如何鏈的CSS()與延遲()

如何鏈jQuery的CSS規則延遲?

$('.two').css('background','blue').delay(11800).css('background','red');
.two{ 
 
    height:100px; 
 
    width:300px; 
 
    background:blue; 
 
} 
 
.ok{ 
 
    display:none; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="ok">hey</div> 
 
<div class="two"></div>

+0

[的jsfiddle從複製的OP的示例的(https://jsfiddle.net/k13sazuz/2/) – Vucko

+1

只要使用'的setTimeout()'? [檢查它](https://jsfiddle.net/k13sazuz/3/) – skobaljic

回答

-1
$.fn.delayCss=function(Time,Name,Value){ 
var This=this; 
setTimeout(function(){ 
This.css(Name,Value); 
},Time); 
return this; 
}; 
$('.two').delayCss(1000,'background','red'); 
+3

你應該添加* how *這個工程的解釋 –