简体   繁体   English

我想向一个元素添加一个事件侦听器,当相应的元素滚动到视图中时会触发该事件

[英]I want to add an event listener to an element which gets fired when the corresponding elements is scrolled into the view

How can I add such an event listener to an element? 如何将这样的事件侦听器添加到元素? My motive is to highlight elements in nav bar when the page is scrolled into the corresponding section. 我的动机是当页面滚动到相应部分时,突出显示导航栏中的元素。 Thanks 谢谢

There is a plugin i used several times which fit you needs: 我使用了几次适合您需要的插件:

JQuery Inview jQuery的观点

or 要么

Viewport Selectors 视口选择器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 之前被触发的事件(不是之后!)DOM元素在javascript中滚动 - Event that gets fired before (not after!) DOM elements are scrolled in javascript 我想用jQuery滚动到视图中时触发一次事件 - I want to trigger an event once when scrolled into view with jQuery 添加事件侦听器时触发的事件处理程序 - Event handler fired when add a event listener 当我在D3中触发的事件中删除相应的元素时,如何删除元素的事件侦听器? - How to remove event listener of an element when I remove the corresponding element in the midst of the event being triggered in D3? Chrome获取下载文件时会触发哪个JS事件? - Which JS event is fired when Chrome gets the download file? 仅当用户滚动到页面底部时,如何添加显示DOM元素的jQuery事件监听器(在这种情况下为iframe) - How do I add a jQuery Event Listener that show a DOM element in this case an iframe only if the user has scrolled to the bottom of the page 当元素滚动到视图中时,jQuery Waypoints添加类 - jQuery Waypoints add class when element is scrolled into view 滚动到视图中时向元素添加类(可滚动 div) - Add class to element when scrolled into view (scrollable div) Javascript - 如何获取触发事件的元素 - Javascript - How do I pick up which element fired an event 当页面上有多个元素时,即使我使用它们的 ID,JS 事件侦听器也不起作用。 (这是独一无二的) - JS Event listener does not work when there are multiple elements on the page even if i use their ID. ( which is unique )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM