gpt4 book ai didi

javascript - 当元素滚动到 View 中时,jQuery Waypoints 添加类

转载 作者:行者123 更新时间:2023-11-30 16:15:02 29 4
gpt4 key购买 nike

我正在使用 Waypoints检查元素是否滚动到 View 中的插件。当用户向下滚动页面时,我有多个类为 item 的 div,我想为每个类添加一个“已查看”类。

$(".item").waypoint(function(){
$(this).addClass("viewed");
console.log("yey");
});

console.log 有效,但 .addClass 无效。插件不支持$(this)吗?

最佳答案

我终于让它工作了。

$(".item").waypoint(function(){
$(this[0,'element']).addClass("viewed");
});

this 没有指向元素,所以我需要指向它。

关于javascript - 当元素滚动到 View 中时,jQuery Waypoints 添加类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35661889/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com