I have a div that I’m trying to animate to a new height by adding together the height of 3 other divs. I’m not sure why they don’t add together but I could use some help with this, thanks in advance for any suggestions.
var staff_CONTAINER_850_ht = $('#staff_CONTAINER_850').height();
var profile_850_BIO_ht = $('#profile_850_BIO').height();
var profile_850_EDU_ht = $('#profile_850_EDU').height();
var profile_850_CONTACT_ht = $('#profile_850_CONTACT').height();
var profile_TOTAL_ht = profile_850_BIO_ht + profile_850_EDU_ht +
profile_850_CONTACT_ht;
$("#launcher").click(function() {
$("#staff_CONTAINER_850").animate({
height: profile_TOTAL_ht
}, 300);
$("#staff_CONTAINER_850").animate({
marginTop: staff_CONTAINER_850_ht* -1
}, 300);
$("#profile_850_HEADER").animate({
marginTop: 45
}, 300);
$("#profile_850_BIO").delay(120).animate({
marginTop: 10
}, 450);
$("#profile_850_EDU").delay(220).animate({
marginTop: 10
}, 450);
$("#profile_850_CONTACT").delay(320).animate({
marginTop: 10
}, 450);
});
Make sure that you are running the code on document.ready:
If you don’t then the heights will all be
null, and you’ll be trying to set the height on a non-existent element.