jQuery: How can I animate to a taller height with the height being added to the top of the element?
Posted
by Jannis
on Stack Overflow
See other posts from Stack Overflow
or by Jannis
Published on 2010-03-17T05:16:13Z
Indexed on
2010/03/17
5:21 UTC
Read the original article
Hit count: 371
Hi, I have a simple problem but I am not sure how to solve it.
Basically I have some hidden content that, once expanded, requires a height of 99px. While collapsed the element holding it section#newsletter
is set to be 65px in height.
LIVE EXAMPLE: http://dev.supply.net.nz/asap-finance-static/
On the click of a#signup_form
the section#newsletter
is expanded to 99px using the following jQuery:
$('#newsletter_form').hide(); // hide the initial form fields
$('#form_signup').click(function(event) {
event.preventDefault(); // stop click
// animate
$('section#newsletter').animate({height: 99}, 400, function() {
$('#newsletter_form').show(300);
})
});
All this works great except for the fact that this element sits in a sticky footer so its initial height is used to position it.
Animating the height of this element causes scrollbars on the browser, because the 34px added are added to the bottom of the element, so my question:
How can I add these 34px to the top of the element so the height expands upwards into the body not downwards?
Thanks for reading, I look forward to your help and suggestions.
Jannis
© Stack Overflow or respective owner