Code is as shown below.
$('p:first').toggle(function() {
$(this).animate({'height':'+=150px'}, 2000, 'linear');
}, function() {
$(this).animate({'height':'-=150px'}, 2000, 'swing');
});
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you change both attributes to “150px” by removing the
+=and the-=, then both sides of your toggle are animating to the same height so there will be no visual movement. It might move to 150px when you first hover, but then it won’t move again.The point of the
+=150pxis to add 150px to the existing height whatever it is. The point of the-=150pxis to subtract 150px from the existing height (thus reversing the prior addition).If you want to remove the
+=and the-=, then you need to set two different heights in the two arms of the toggle to define the two sizes that you want to toggle between.