How to automatically execute a Javascript function whenever width or height of a div changes? I don't want to trigger an event manually. I am using jQuery.
-
When would the width or height of the div change? As a result of what? Window resizing? Content changes?Jeff B– Jeff B2010-11-24 00:29:37 +00:00Commented Nov 24, 2010 at 0:29
-
Changes by jQuery's width() function.Tony_Henrich– Tony_Henrich2010-11-24 00:42:26 +00:00Commented Nov 24, 2010 at 0:42
Add a comment
|
2 Answers
Try this plugin:
From their example:
$("#unicorns").resize(function(e){
// do something when #unicorns element resizes
});
Comments
Unfortunately there is no built in support for this. the .resize() function is only for the window object, and the .change() function is only for input elements. You will need to do it manually to the best of my knowledge.
1 Comment
Macy Abbey
Doh, got owned by the guy below! :)