0

我想在 div 高度变化时运行一个函数,如果 div 高度增加,我想向 body 添加一个类,如果高度降低到0.

就像是:

$('.mydiv').change(function(){
    // add class to boy if height increase
})
4

1 回答 1

0
$('.mydiv').resize(function() {
  if($(this).height() > 400){
    $('body').removeClass('normal height bigheight').addClass('bigheight');
  } else if ($(this).height() > 200){
    $('body').removeClass('normal height bigheight').addClass('height');
  } else if ($(this).height() > 0){
    $('body').removeClass('normal height bigheight').addClass('normal');
  } else {
    $('body').removeClass('normal height bigheight');
  }
});
于 2013-08-02T12:51:14.577 回答