jQuery Tutorial

jQuery Animation Using Relative Values & Predefined Values

Table of Contents

  • jQuery Animation With Relative Values
  • jQuery Animation With Predefined Values

jQuery Animation With Relative Values

This method can also define relative values (the value is close to the element's current value). This is accomplished by appending += or -= to the value:

$("button").click(function(){
  $("div").animate({
    left: '250px',
    height: '+=150px',
    width: '+=150px'
  });
}); 

jQuery Animation With Predefined Values

You can even specify the animation value for a property as "display," "hide," or "toggle":

$("button").click(function(){
  $("div").animate({
    height: 'toggle'
  });
}); 
Did you find this article helpful?