简体   繁体   中英

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 ?

$(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).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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM