Example of :animated in jQuery
February 21, 2013
:animated in jQuery do a very interesting task. Let’s suppose if we have some elements which are animated by slideToggle. Then :animated can select those animated ids. And do some task for those elements like we can change the CSS properties for those elements. :animated can be used as
$("div:animated").toggleClass("conmove");
<!DOCTYPE html> <html> <head> <style> div {background:green; border:1px width:70px; height:60px; } div.conmove { background:red; } </style> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <button id="click">Click To Test</button> <div id="mid"></div> <script> $("#click").click(function(){ $("div:animated").toggleClass("conmove"); }); function conAimate() { $("#mid").slideToggle("medium", conAimate); } conAimate(); </script> </body> </html>