【发布时间】:2022-01-12 19:31:49
【问题描述】:
我使用这个 JQuery 代码有一个粘性的“转到顶部”按钮:
//sticky back-to-top button
(function (t) {
t(window).bind("scroll", function () {
500 < t(this).scrollTop()
? t(".back-to-top").fadeIn(400)
: t(".back-to-top").fadeOut(400);
}),
t(".back-to-top").click(function () {
t("html, body").animate({ scrollTop: "0px" }, 500);
});
})(jQuery);
此代码可以正常工作。 但我想当这个粘性按钮到达一个名为“go-top”的特定类时消失。对不起我的英语不好。
【问题讨论】:
-
我不完全理解你的问题,但使用
addClass或removeClassjquery 方法应该可以工作
标签: javascript html jquery