jQuery:如何用延迟()链接css()

时间:2016-04-05 21:30:39

标签: javascript jquery html css

fid:https://jsfiddle.net/k13sazuz/

如何在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>

1 个答案:

答案 0 :(得分:-1)

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