<分区>
标签 javascript jquery html css
<分区>
更新:因为每个人都挂断了窗口调整大小
我在一个可调整大小的 div 中有一个 div,我想检测子 div 的大小调整。我知道 .on('resize') 仅适用于窗口。我的问题完全基于子 div 的大小调整。
<div id='main_wrapper'>
<div id = 'child_div'>
</div>
</div>
html,
body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
#main_wrapper {
height: 300px;
width: 300px;
background-color: blue;
}
#child_div{
height: 100%;
width: 100%;
}
$('#main_wrapper').resizable();
$('#child_div').on('resize', function() { //i know this isn't proper, how to do this is my question.
alert('i changed');
})
https://jsfiddle.net/cyclingpaper/2kksqoLs/
感谢您的宝贵时间。
最佳答案
调整大小事件只针对窗口对象。你不能将它附加到除最顶部之外的另一个 DOM 树元素。
关于javascript - jQuery 未检测到 div 调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34201752/