$(document).ready(function() { $(window).scroll(function() { if ($(this).scrolltop() > 150) { $('.back-to-top').fadein(500); } else { $('.back-to-top').fadeout(500); } }); $('.back-to-top').click(function(event) { event.preventdefault(); $('html, body').animate({scrolltop: 0}, 500); }) }); above javascript code back-to-top button , want show out when scroll page.
however, found out button show out in beginning when refresh page , hide again when scroll < 150 , show again when scroll > 150.
what can hide in beginning , show out when scroll > 150?
use below code. hide button on page load button display per condition 150 >
$(document).ready(function() { $('.back-to-top').hide(); // code here or using css
.back-to-top{ display:none; }
Comments
Post a Comment