Reputation: 1849
I'm using this plugin to check if a size of a DIV is changed:
http://benalman.com/projects/jquery-resize-plugin/
And it works just fine, but I don't want to just detect if a DIV is resized, I want to detect if the height of a DIV is increased or reduced!
How this could be achieved?
Thanks
Upvotes: 0
Views: 8887
Reputation: 9975
Use a variable to keep track of the height:
var previousHeight = jQuery("#myDiv").height();
$("#myDiv").resize(function(e){
// do something when element resizes
if(previousHeight < jQuery(this).height()){
alert("now I'm bigger");
}else{
alert("Now I'm smaller");
}
//update previousHeight for next use
previousHeight = jQuery(this).height();
});
Upvotes: 1