How to detect DIV's dimension changed?

后端 未结 25 2786
抹茶落季
抹茶落季 2020-11-22 06:14

I\'ve the following sample html, there is a DIV which has 100% width. It contains some elements. While performing windows re-sizing, the inner elements may be re-positioned,

25条回答
  •  借酒劲吻你
    2020-11-22 06:35

    Take a look at this http://benalman.com/code/projects/jquery-resize/examples/resize/

    It has various examples. Try resizing your window and see how elements inside container elements adjusted.

    Example with js fiddle to explain how to get it work.
    Take a look at this fiddle http://jsfiddle.net/sgsqJ/4/

    In that resize() event is bound to an elements having class "test" and also to the window object and in resize callback of window object $('.test').resize() is called.

    e.g.

    $('#test_div').bind('resize', function(){
                console.log('resized');
    });
    
    $(window).resize(function(){
       $('#test_div').resize();
    });
    

提交回复
热议问题