如何檢測DIV的尺寸變化?我有下面的示例html,有一個100%寬度的DIV。它包含了一些元素。在執行窗口調整大小時,內部元素可能被重新定位,div的尺寸可能會改變。我在問是否有可能將div的維度更改事件掛鉤?怎么做呢?目前,我將回調函數綁定到目標DIV上的jQuery調整大小事件,但是沒有輸出控制臺日志,請參見下面的內容:<html><head>
<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script type="text/javascript" language="javascript">
$('#test_div').bind('resize', function(){
console.log('resized');
});
</script></head><body>
<div id="test_div" style="width: 100%; min-height: 30px; border: 1px dashed pink;">
<input type="button" value="button 1" />
<input type="button" value="button 2" />
<input type="button" value="button 3" />
</div></body></html>
如何檢測DIV的尺寸變化?
呼如林
2019-07-04 14:53:06