您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 巢湖分类信息网,免费分类信息发布

jquery :animated选择器如何使用?

2024/3/1 12:05:00发布13次查看
谁能给我写个简单的例子,格式清楚的!
// 在一个动画中同时应用三种类型的效果,animate()里面用键值对表示 $("#a").click(function(){ //绑定一个点击事件 $("#b").animate({ width: "90%", //设置点击之后需要改变之后的样式,以达到动画效果 height: "100%", fontsize: "10em", borderwidth: 10 }, 1000 ); //动画的过度时间 1000<a href="https://www.baidu.com/s?wd=%e6%af%ab%e7%a7%92&tn=44039180_cpr&fenlei=mv6quakxtzn0izrqihckpjm4nh00t1y3nwfyphr3nhmsp1nhrjmz0zwv5hcvrjm3rh6spfkwumw85hfynjn4nh6sgvpst6kdthsqpzwytjceqlgcpyw9uz4bmy-bii4wuvyetgn-tlwguv3ephfyphcsrhr3" target="_blank" class="baidu-highlight">毫秒</a> });
:animated 用于判断一个元素是否【尚在】执行动画
$(function() { // 开始动画 $("#box").animate({left: 500}, 5000); $(document).on("click", function() { // 在选择器中使用 if($("#box:animated").length) { $("body").append("<p>#box 尚在动画</p>"); } // 在 is 中使用 if(!$("#box").is(":animated")) { $("body").append("<p>#box 动画停止</p>"); } }); });
<div id="box" style="width: 100px; height: 100px; background: #f00; position: absolute;"></div>
以前学习的时候写的,希望对你有帮助。
<html> <head> <script type="text/javascript" src="jquery-1.7.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("#box").animate({height:300,width:400},"slow"); $("#box").animate({width:300},"fast"); $("#box").animate({height:100},"normal"); $("#box").animate({width:100},"slow"); }); }); </script> </head> <body> <button>click me</button> <div id="box" style="background-color:#000000;height:100px;width:100px"> </div> </body> </html>
语法结构:
$(":animated")
此选择器一般也要和其他选择器配合使用,比如类选择器和元素选择器等等。例如:
$("li:animated").css("background-color","blue")
以上代码能够将正在执行动画下过的li元素的背景颜色设置为蓝色。
如果不和其他选择器配合使用,则默认状态是和*选择器配合使用,例如$(:animated)等同于$(*:animated)。
以上就是jquery :animated选择器如何使用?的详细内容。
巢湖分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录