setTimeout
<div class="dd" style="width:200px; height:200px; background-color:red">
</div>
<script type="text/javascript">
$(function(){
$(".dd").click(function(){
$(this).css("background-color","green");
setTimeout(function(){
$(this).css("background-color","red");
},200);
});
});
</script>
$(".dd").click(function(){
$(this).css("background-color","green");
var _this = this;
setTimeout(function(){
$(_this).css("background-color","red");
},200);
});
使用setTimeout、setInterval函数后,回调函数里的this会指向window,而不是你当时绑定的对象。