简体   繁体   English

向下滚动certian amont时,我试图使div出现?

[英]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.

相关问题 我试图让我的导航栏在我向下滚动时向上缩回,然后在我向上滚动时再次出现,但它没有做任何事情 - 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 向下滚动页面时,如何使导航栏下方出现阴影? - How do I make a shadow appear under the navigation bar when I scroll down the page? 我试图让div在点击时消失并使另一个div出现在我编写的地方并使用javascript运行代码; - I am trying to make a div disappear on click and make another div appear in its place I have wrote and run code using javascript; 当我在带有溢出滚动的 div 中向下滚动时如何播放视频 - How to make a video play as I scroll down in a div with overflow scroll 我试图在用户向下滚动时修复我的导航栏,但是当我向下滚动时它不会停留 - I'm trying to make my navbar fixed when the user scrolls down, but when I scroll down it doesn't stay 我试图让图像出现 onclick,并且脚本没有执行 - I am trying to make image appear onclick, and the script is not executing 我正在尝试制作一个事件侦听器,当您单击图像时它会显示一个 div - I'm trying to make an event listener that makes it to where when you click on an image it makes a div appear 即使向下滚动也如何使div高度整页 - How to make div height whole page even when I scroll down 当我单击其他div时使div出现 - Make div appear when i click in other div 当您使用Jquery按下按钮时,我试图使页面滚动速度变慢吗? - I am trying to make my page scroll slower when you press a button using Jquery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM