[英]I am trying to make a div appear when i scroll down a certian amont ?
just trying to make a div appear when I scroll down with some js and html, doesnt seem to be working and im not sure why ? 当我向下滚动一些js和html时,只是试图使div出现,这似乎没有用,并且我不确定为什么吗?
$(document).scroll(function() {
var y = $(this).scrollTop();
if (y > 200) {
$('.aboutfilmandcrew').fadeIn();
} else {
$('.aboutfilmandcrew').fadeOut();
}
});
#aboutfilmandcrew {
width: 100%;
float: left;
}
You should try with window instead of document : 您应该尝试使用window而不是document:
$(window).on('scroll', function() { ... });
The rest of your code looks correct, but in the javascript you're selecting the div with the class filmandcrew, while your css is styling the div with the id filmandcrew. 您的其余代码看起来正确,但是在javascript中,您选择的是带有filmandcrew类的div,而CSS则使用id filmandcrew来对div进行样式设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.