[jQuery] redundancy - dimensions plugin and toggle?
I've got some toggle code where I want to check the height of something
using the dimensions plugin and am not sure the best way to do this:
$('.container').toggle(
function() {
$(this).removeClass('right').addClass('down');
// check height of window and if too
tall - show bottom nav
if ($('#wrapper').height() > 400) {
$('#bottomnav').show();
} else {
$('#bottomnav').hide();
};
},
function() {
$(this).removeClass('down').addClass('right');
// check height of window and if too
tall - show bottom nav
if ($('#wrapper').height() > 400) {
$('#bottomnav').show();
} else {
$('#bottomnav').hide();
};
});
Seems like I should be able to simplify the height check instead of
doing everything twice???
Thanks,
Jim