我不知道这是否简单,但我只是想不出用Waypoint.js做什么--我需要在用户到达的时候给#粘贴顶部添加一个类,例如,100 ex的滚动,知道怎么做吗?对我不起作用。提前感谢
发布于 2014-09-26 15:43:01
这实际上不是jQuery路径点的用例。它的设计是为了测试特定元素离屏幕顶部有多远,而不是用户滚动的距离。
但是,您可以很容易地使用jQuery来做您想做的事情:
$(document).on('scroll', function () {
// if the scroll distance is greater than 100px
if ($(window).scrollTop() > 100) {
// do something
$('#stickytop').addClass('myClass');
}
});或者香草JavaScript:
document.addEventListener('scroll', function () {
if (window.scrollY > 100) {
var el = document.getElementById('#stickytop');
el.className = el.className + " myClass";
}
})https://stackoverflow.com/questions/26063187
复制相似问题