jquery animate()

Among several effects, there also exists animation in jquery. Yes, we can also animate a jquery element such as a div or button using the animate() method.

Syntax

$(selector).animate({params},speed,callback);

Params is the required parameter and it defines the CSS properties to be animated. properties may include left,right, opacity and many others

Speed and callback are optional parameter. Speed specifies the duration of the effect and can take values: “slow”, “fast”, or milliseconds. Callback parameter is a function to be executed after the animation completes.

$("button").click(function(){
  $("div").animate({
    left: '200px',
    opacity: '0.7',
    height: '120px',
    width: '120px'
  });
});

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a free website or blog at WordPress.com.

Up ↑

Create your website at WordPress.com
Get started
%d bloggers like this: