【问题标题】:Onresize not triggering on resizeOnresize 不会在调整大小时触发
【发布时间】:2019-06-05 09:34:34
【问题描述】:

我对 JS onresize 有点困惑,并针对此问题查看了 W3schools。但这给我带来了更多的问题。所以我决定在 Stack 上问它。

为什么this 没有被this 触发?

所以基本上:

HTML

<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>

CSS

div {
  border: 2px solid;
  padding: 20px;
  width: 300px;
  resize: both;
  overflow: auto;
}

Javascript

function test() {
    alert("Resized");
}

JSFiddle:https://jsfiddle.net/v95yLtxd/

我有点期待 JS 函数在调整大小时执行。

为什么这没有像我预期的那样工作?

【问题讨论】:

标签: javascript html css


【解决方案1】:

调整大小 eventdocument(不是任何元素)调整大小时触发。 W3schools 对此并不清楚。 CSS 调整大小属性不会触发调整大小事件。

所以这不是您要查找的事件。有关调整 div 大小的详细信息,请参阅 Connum 的评论。

【讨论】:

  • 谢谢。我没有意识到这一点!
猜你喜欢
  • 1970-01-01
  • 2015-07-30
  • 2015-03-06
  • 1970-01-01
  • 2019-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多