1

I know about $(window).resize(function () {.....}); but this only works whenever the window is resized.

I tried attaching this event to a e.g. $("#some-div").resize(function () {.....}); and it won't work.

Is there some other method using pure Javascript or jQuery?

JSFiddle

Thanks

Kawd
  • 4,122
  • 10
  • 37
  • 68

2 Answers2

0

Maybe this can help.

https://hacks.mozilla.org/2012/05/dom-mutationobserver-reacting-to-dom-changes-without-killing-browser-performance/

It might be hard to detect changes just by using events. Adding text to a div may cause a resize but the event triggered does not reveal that.

-1

You can try

var divresize = $('#div_name').width();
        $(window).resize(function(){
            if($('#div_name').width() < divresize){
                alert('Your div has been resize')
            }
        })
Rodrigo Zuluaga
  • 497
  • 3
  • 11
  • This only works if the window resizes. The window will not necessarily resize every time my div does. – Kawd Mar 10 '14 at 10:15
  • Well actually this is what you ask, amplify the resquest to see what you're looking for to achieve with this ;)!!! – Rodrigo Zuluaga Mar 15 '14 at 14:44