2

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.

2
  • When would the width or height of the div change? As a result of what? Window resizing? Content changes? Commented Nov 24, 2010 at 0:29
  • Changes by jQuery's width() function. Commented Nov 24, 2010 at 0:42

2 Answers 2

5

Try this plugin:

From their example:

$("#unicorns").resize(function(e){
  // do something when #unicorns element resizes
});
Sign up to request clarification or add additional context in comments.

Comments

0

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

Doh, got owned by the guy below! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.