我的js中有这个脚本,我在滚动时改变了导航的颜色,导航变成了白色。当我想停用脚本时,我会尝试响应式
$(document).ready(function(){
var scroll_start = 0;
var startchange = $('.change-col-nav');
var offset = startchange.offset();
if (startchange.length){
$(document).scroll(function() {
scroll_start = $(this).scrollTop();
if(scroll_start > offset.top) {
$(".navbar-inverse").css({
"background-color": "#fff",
"border-bottom": "1px solid #febe10",
"transition": "all 0.4s cubic-bezier(0.000, 0.000, 0.580, 1.000)"
});
}
else
{
$('.navbar-inverse').css({
'background-color': 'transparent',
"border-bottom": "0",
});
}
});
}
});
我想在最小宽度 768 最大宽度 991 时使该脚本处于非事件状态,我该怎么做?
最佳答案
将其包含在 if 中,如下所示:
$(document).ready(function(){
// ... more code here
$(document).scroll(function() {
if ($(window).width() > 768 && $(window).width < 991) {
return;
}
// .... rest of your normal code here
})
})
关于javascript - 响应式 jquery 处于非事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39169304/