articles

JQuery animate method

Sachindra Singh9316 22-Feb-2011

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



Updated 07-Sep-2019

Leave Comment

Comments

Liked By