[英]uBlock blocking “Go back to top” button (JavaScript)
I have simple code of this function on website, but uBlock block the button.我在网站上有这个 function 的简单代码,但是 uBlock 阻止了按钮。
The code is blocked the second time when I refresh the page, works fine the first time.当我刷新页面时,代码第二次被阻止,第一次工作正常。 To start working again you need to restart web browser.
要重新开始工作,您需要重新启动 web 浏览器。
JS code: JS代码:
$(document).ready(function(){
$(window).scroll(function () {
if ($(this).scrollTop() > 50) {
$('#go-to-top').fadeIn();
} else {
$('#go-to-top').fadeOut();
}
});
// scroll body to 0px on click
$('#go-to-top').click(function () {
$('body,html').animate({
scrollTop: 0
}, 1000);
return false;
});
});
CSS code: CSS 代码:
.go-to-top {
position: fixed;
bottom: 25px;
right: 25px;
display: none;
}
HTML code: HTML 代码:
<a id="go-to-top" href="#" class="btn btn-light btn-lg go-to-top" role="button">Go to top</a>
For some reason uBlock blocks elements with id and class name "go-to-top".出于某种原因,uBlock 会阻止具有 id 和 class 名称“go-to-top”的元素。
Just change their names to, for example, "go-up" and everything starts working.只需将他们的名字改为“go-up”,一切都会开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.