Home > DeveloperSection > Beginner > JQuery animate method

JQuery animate method


JQuery JQuery 
Ratings:
0 Comment(s)
 5314  View(s)
Rate this:

Using JQuery animate method

With the help of animate () method we can create animation effects on html page .In this article I am using animate method to give animation effect on image. It means image height and width will be resized when mouse pointer will over on image as shown below:

Code:

<head>

    <title>Animate</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

   <script type="text/javascript">

       $(document).ready(function()       {

           $("div").mouseover(function()//mouseover function will execute when mouse pointer will reach on <div>element

            {

               $("img").animate({ height: 300 }, "slow");//image height will change by using animate method

               $("img").animate({ width: 300 }, "slow");     

   $("img").animate({ height: 100 }, "slow");

               $("img").animate({ width: 100 }, "slow

           });

       }

   );

    </script>

</head>

<body>

<div  style=" height:100px;width:100px;position:relative"> <img src="Lighthouse.jpg" id="img" style=" height:100px;width:100px;position:relative" </div>

</body>

</html>

Screenshot

JQuery animate method

Image height and width will change when mouse pointer will over on image as shown below:

Screenshot

JQuery animate method


Don't want to miss updates? Please click the below button!

Follow MindStick