Javascript jqueryif-else在滚动中
我想在滚动时更改CSS或菜单栏,并在滚动停止使用if-else时恢复旧CSS。 这就是我到目前为止所做的Javascript jqueryif-else在滚动中,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我想在滚动时更改CSS或菜单栏,并在滚动停止使用if-else时恢复旧CSS。 这就是我到目前为止所做的 if ($(window).scroll(function () { $('#nav').css('opacity', '0.85'); } else { $('#nav').css('opacity', '1'); }); 无if语句的工作代码 $(document).scroll(function() { $('#nav').css('opacity', '0.
if ($(window).scroll(function () {
$('#nav').css('opacity', '0.85');
} else {
$('#nav').css('opacity', '1');
});
无if语句的工作代码
$(document).scroll(function() {
$('#nav').css('opacity', '0.85');
});
使用滚动和滚动停止
$(document).on("scroll", function() {
$('#nav').css('opacity', '0.85');
});
$(document).on("scrollstop",function(){
$('#nav').css('opacity', '1');
});
试试这个
scrolling = "Scrolling",
stopped = "Stopped";
$( window ).scroll(function() {
console.log(scrolling);
clearTimeout( $.data( this, "scrollCheck" ) );
$.data( this, "scrollCheck", setTimeout(function() {
console.log( stopped );
}, 250) );
});
要显示的小提琴吗?
if($(窗口)。滚动
非常奇怪。你想在if
中签入什么?if和大括号完全不正常。$(窗口)。滚动()
将处理程序绑定到scroll事件。它不会返回任何您可以使用进行测试的内容(如果
)。您可以为相同的内容提供可能的副本。上述方法在jquery mobile中可用。但您可以使用注释中提到的链接。