[英]I'm trying to make my navbar retract upwards when I scroll down and then appear again when I scroll up, but it doesn't do anything
[英]I am trying to make a div appear when i scroll down a certian amont ?
当我向下滚动一些js和html时,只是试图使div出现,这似乎没有用,并且我不确定为什么吗?
$(document).scroll(function() {
var y = $(this).scrollTop();
if (y > 200) {
$('.aboutfilmandcrew').fadeIn();
} else {
$('.aboutfilmandcrew').fadeOut();
}
});
#aboutfilmandcrew {
width: 100%;
float: left;
}
您应该尝试使用window而不是document:
$(window).on('scroll', function() { ... });
您的其余代码看起来正确,但是在javascript中,您选择的是带有filmandcrew类的div,而CSS则使用id filmandcrew来对div进行样式设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.