jQuery :animated选择器
:animated选择器语法
$(':animated')
:animated选择器语法解析
jQuery中的:animated选择器可以用于匹配选择所有设置了动画的HTML元素。注意,一般指的是通过jQuery设置的动画,而不是通过CSS设置的动画。
:animated选择器实例代码
如下实例,通过jQuery为第一个div设置了动画的属性,然后通过:animated选择器匹配选择该元素,并修改其背景颜色:
<div id='d1'></div>
<br>
<div id="d2"></div>
<br>
<button id="bt1">笨鸟工具</button>
<style>
#d2{width:100%;height:30%;background-color:green;}
#d1{height:30%;background-color:blue;}
</style>
<script>
$(document).ready(function(){
function animatedDiv(){
$("#d1").animate({width:"30%"},"slow");
$("#d1").animate({width:"100%"},"slow",animatedDiv);
}
animatedDiv();
$("#bt1").click(function(){
$(":animated").css("background-color","orange");
});
});
</script>
免责声明:内容仅供参考,不保证正确性!