I’m trying to create slidingUp divs with variable ‘top’ heights, so that one div may slideUp 700px, while another (with less content) slidesUp only 400px. Currently, the divs all slideUp at the same height. There are no div height declarations in the css. My script:
$(document).ready(function(){
var oldHeight;
$('a.menubtn').click(function(){
var newHeight;
if ($(this.id) == 'work') {
newHeight = 700;
}
else { if ($(this.id) == 'services') {
newHeight = 400;
}
else { if ($(this.id) == 'about') {
newHeight = 400;
}
else {
newHeight = 300;
}
}
}
if ($('.active').length > 0) {
$('.active').removeClass('active').animate({'top': '+=' + oldHeight + 'px'}, '200');
$('div#contents_'+ this.id).addClass('active').animate({'top': '-=' + newHeight + 'px'}, '200');
oldHeight = newHeight;
}
else
$('div#contents_'+ this.id).addClass('active').animate({'top': '-=' + newHeight + 'px'}, '200');
oldHeight = newHeight;
}
return(false);
});
})
TIA.
Your
ifstatements are wrong.This:
should be:
It would be cleaner if you changed the structure of the
ifstatements to be like this: