たぶん要素の幅が変更された場合はさらにonResizeチェックはほとんどの機能を使用する際に役立つことを願ってのために働いています。ブラウザのサイズを変更し、コンソールログ結果をチェックアウトします。
$(window).resize(function(){
var obj = $('#at')[0];
if(detectResize(obj)) console.log('resize detected');
});
function detectResize(getObject){
var getWidth = getObject.getBoundingClientRect().width;
if(getObject.currentWidth===getWidth){
return false;
} else {
getObject.currentWidth = getWidth;
return true;
}
}
#at{
width:100%;
max-width:400px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="at" style="background:red">
This is a div, you can click on me or resize me.
</div>
私は唯一のサイズを変更するために使用しますが、あなたのケース内の要素は、イベントのサイズを変更したい$(ウィンドウ)を知っています。私も解決策を探しています –
私はresizeイベントはウィンドウオブジェクト上でのみ使用できると信じていますので、あなたは '$(window).resize()'を使う必要があります。要素のサイズは直接ですか? – Jhecht
はい、正確に要素のサイズ変更イベントが必要です。 –