javascript - Show div after scroll and hide div at the end of the page -
i try show div after scrolling down 1500px , want hide div when 90% of page scrolled (so, @ end of page).
my code works fine show after 1500px don't know how hide when end of page reached.
this code:
<style type="text/css"> #sample { background: #fff none repeat scroll 0 0; position: fixed; bottom: 0; height: auto; max-height:100px; width: 100%; z-index: 999; display:none; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).scroll(function() { var y = $(this).scrolltop(); if (y > 1500) { $('#sample').fadein(); } else { $('#sample').fadeout(); } }); </script> <div id="sample"> content... </div>
i glad if can me problem. many thanks.
you this:
var y = $(this).scrolltop(); if (y > 1500 && y < ($(document).height() * 0.9)) { $('#sample').fadein(); } else { $('#sample').fadeout(); }
Comments
Post a Comment