onscroll for div [英] onscroll for div
问题描述
div元素没有 onscroll
事件处理程序?
我的页面上的行为似乎并没有显示识别div onscroll
事件处理程序。
< div id ='bd'onscroll ='alert(Scroll Called);'>< / div>
另外,
Do滚动事件会滚动到窗口滚动事件,如每个DOM事件冒泡?
onwheel
事件,而不是。
- div有
溢出:auto
,overflow:scroll
,overflow-y:scroll
等 -
- 鼠标移动实际上会导致滚动条滚动。
所以 onscroll
事件并不适合检测一般的鼠标滚轮移动。
c> onwheel
事件在HTML 5中是新的。根据w3schools ,它很宽虽然支持。 Does a div element not have an onscroll
event handler?
The behaviour on my page doesn't seem to indicate the div onscroll
event handler is recognized.
<div id='bd' onscroll='alert("Scroll Called");'></div>
Also,
Do div scroll events roll up to window scroll events, as per DOM event bubbling ?
Depending on which version of HTML you're using, you could use the onwheel
event, instead.
The onscroll
event works only if all the following are true:
- The div has
overflow: auto
,overflow: scroll
,overflow-y: scroll
, etc. - The div currently has a visible scrollbar that can scroll.
- The mouse movement actually causes the scrollbar to scroll.
So the onscroll
event is not really suited for detecting general mouse wheel movement.
Please note that the onwheel
event is new in HTML 5. According to w3schools, it is pretty widely supported, though.
这篇关于onscroll for div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!