0

I wan to run a function on div height change, I want to add a class to body if div height increased and remove the class if height decrease to 0.

Something like:

$('.mydiv').change(function(){
    // add class to boy if height increase
})
thomasfedb
  • 5,990
  • 2
  • 37
  • 65
user007
  • 3,203
  • 13
  • 46
  • 77
  • See http://stackoverflow.com/questions/6726406/how-to-detect-and-change-div-height-in-jquery?rq=1 – rink.attendant.6 Aug 02 '13 at 12:47
  • possible duplicate of [Detecting when a div's height changes using jQuery](http://stackoverflow.com/questions/172821/detecting-when-a-divs-height-changes-using-jquery) – Joe Aug 02 '13 at 12:49

1 Answers1

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');
  }
});
Guillaume Lhz
  • 904
  • 5
  • 16