i have code performs following task: when page loaded hidden; otherwise shown. code have written makes perfect sense seems work once when page has loaded.
$(document).ready(function(){ settimeout(function(){ xyz = $('.verb_logo_w'); if(document.body.scrolltop === 0){ xyz.hide(); }; window.onscroll = function(e){ xyz.show(); }; },10); });
you need add hide function scroll event too:
$.scrolltop = function () { if ($(document).scrolltop() === 0) { $('.verb_logo_w').hide(); } else { $('.verb_logo_w').show(); } }; //onscroll $(window).on('scroll', function () { $.scrolltop(); }); //init $.scrolltop();
and move block outside of timeout.
here working jsfiddle.
text appears, if scrolltop
value not 0 @ page load, , on scroll.
Comments
Post a Comment