jquery - How to remove JQuery scrolltop function from a specific page
问题描述
Basically, I have a navbar which changes the logo image from transparent to full colour on scroll.
I don't want this to happen on a certain page, for example, my search results page (/toursearch).
This is the JQuery I am using below.
if (windowWidth > 991) {
$(window).scroll(function () {
if ($(this).scrollTop() > 50) {
$('.logo-desk a img').attr('src', '/Includes/images/logo/holts-logo-fill.png');
}
if ($(this).scrollTop() <= 0) {
$('.logo-desk a img').attr('src', '/Includes/images/logo/holts-logo-trans.png');
}
});
}
Any suggestions would be great.
Many thanks in advance!
解决方案
脚本.js
var check = $("[disbled-scrollFun=true]");
if (!check) {
function scrollFun() {
if (windowWidth > 991) {
$(window).scroll(function() {
if ($(this).scrollTop() > 50) {
$('.logo-desk a img').attr('src', '/Includes/images/logo/holts-logo-fill.png');
}
if ($(this).scrollTop() <= 0) {
$('.logo-desk a img').attr('src', '/Includes/images/logo/holts-logo-trans.png');
}
});
}
}
}
任何.html
添加到正文或任何标签
<body disbled-scrollFun="true">
</body>
推荐阅读
- python - Pandas:在多列之间线性插值多个步骤
- python - cv2.circle int() 参数必须是字符串或数字,而不是“元组”
- django - Django 从数据库中获取随机对象
- java - Azure Webapp Java Rest API 端点不起作用
- python - 我想在Python循环中的每个图旁边绘制每个图例
- c# - 线程进程在执行完整代码之前退出
- applescript - 在applescript中设置时间码
- unicode - 终端中缺少 Unicode 字符
- python - python请求没有得到整页
- powershell - Powershell 和 Web 服务:其中一个参数是 DateTime……我怎样才能传递那个值?