Reputation: 857
I'm a little confused by the JS onresize
and checked out W3schools for this issue. But that brought me even more questions. So I decided to ask it on Stack.
Why exactly is this not getting triggered by this?
So basically:
<h1>The resize Property</h1>
<div onresize="test()">
<p>Let the user resize both the height and the width of this div element.</p>
<p>To resize: Click and drag the bottom right corner of this div element.</p>
</div>
<p><b>Note:</b> Internet Explorer does not support the resize property.</p>
div {
border: 2px solid;
padding: 20px;
width: 300px;
resize: both;
overflow: auto;
}
function test() {
alert("Resized");
}
JSFiddle: https://jsfiddle.net/v95yLtxd/
I kind of expected the JS function to be executed on the resizing.
Why is this not working as I expected it to be?
Upvotes: 0
Views: 314
Reputation: 422
The resize event is fired when the document (not any element) is resized. W3schools is not clear on that. The CSS resize property does not fire resize events.
So this is not the event you are looking for. See Connum's comment for details on resizing your div.
Upvotes: 2