正在回答
1回答
同学你好,:animated 选择器是选取当前的所有动画元素。
可以参考如下代码,在点击按钮,有动画的元素背景颜色改变
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> div { background: #98bf21; height: 40px; width: 100px; position: relative; margin-bottom: 5px; } </style> </head> <body> <div></div> <div id="box"></div> <div></div> <button class="btn1">点击按钮,动画元素背景颜色改变</button> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { function aniDiv() { $("#box").animate({ width: 300 }, "slow"); $("#box").animate({ width: 100 }, "slow", aniDiv); } aniDiv(); $(".btn1").click(function() { $(":animated").css("background-color", "blue"); }); }); </script> </body> </html>
希望能帮助到你,欢迎采纳。
祝学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星