Javascript examples for jQuery Selector:animated
jQuery :animated Selector selects all elements that are currently animated.
The following code shows how to select any element that is currently animated.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ function aniDiv(){//from ww w . j a va2 s. co m $("div:eq(0)").animate({width: "50%"}, "slow"); $("div:eq(0)").animate({width: "100%"}, "slow", aniDiv); } aniDiv(); $(".btn1").click(function(){ $(":animated").css("background-color", "blue"); }); }); </script> </head> <body> <button class="btn1">Change color of the animated element</button> <div style="background:blue;">Div 1</div> <div style="background:green;">Div 2</div> <div style="background:yellow;">Div 3</div> <div >Div 4</div> </body> </html>