How to detect DIV's dimension changed?

后端 未结 25 2405
抹茶落季
抹茶落季 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:48

    jQuery(document).ready( function($) {
    
    function resizeMapDIVs() {
    
    // check the parent value...
    
    var size = $('#map').parent().width();
    
    
    
    if( $size < 640 ) {
    
    //  ...and decrease...
    
    } else {
    
    //  ..or increase  as necessary
    
    }
    
    }
    
    resizeMapDIVs();
    
    $(window).resize(resizeMapDIVs);
    
    });
    

提交回复
热议问题