Home  >  jQuery

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");
 
Here :animated has been applied on div. on all animated div block can be provided toggleClass i.e different CSS properties. Find the example.
<!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>
 
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us