How to automatically execute a Javascript function whenever width or height of a div changes?
How to automatically execute a Javascript function w开发者_如何学Pythonhenever width or height of a div changes? I don't want to trigger an event manually. I am using jQuery.
Try this plugin:
- http://benalman.com/projects/jquery-resize-plugin/
From their example:
$("#unicorns").resize(function(e){
// do something when #unicorns element resizes
});
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.
精彩评论