I've the following sample html, there is a DIV which has 100% width.(我有以下示例html,有一个DIV,其宽度为100%。)
It contains some elements.(它包含一些元素。) While performing windows re-sizing, the inner elements may be re-positioned, and the dimension of the div may change.(在执行窗口调整大小时,内部元素可能会重新放置,并且div的尺寸可能会更改。) I'm asking if it is possible to hook the div's dimension change event?(我问是否有可能挂钩div的尺寸更改事件?) and How to do that?(以及如何做到这一点?) I currently bind the callback function to the jQuery resize event on the target DIV, however, no console log is outputted, see below:(我目前将回调函数绑定到目标DIV上的jQuery resize事件,但是,没有控制台日志输出,请参见以下内容:)
<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>
ask by William Choi translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…