[英]javascript not showing div when scrolling up
can someone please help me debugging my jquery scrolling up hiding the div 有人可以帮我调试我的jquery向上滚动隐藏div
here is my javascript code 这是我的JavaScript代码
jQuery(function() { // document ready
var sideBarTop = $('#sticky').offset().top; // position top
var sideBarLeft = $('#sticky').offset().left //position left
jQuery(window).scroll(function(){ // scroll event
var windowTop = $(window).scrollTop(); // returns scroll from top
if(sideBarTop < windowTop) {
$('#sticky').css({position: 'fixed', top: 210, left: sideBarLeft}).fadeIn();
}
else {
$('#sticky').css('position', 'static').fadeOut("slow");
}
});
});
here is my html code 这是我的HTML代码
<div id="sticky">
<ul id="nav">
<li class="current"><a href="#avant">Avant</a></li>
<li><a href="#allure">Allure</a></li>
<li><a href="#eden">Eden</a></li>
</ul>
</div>
please someone help me 请有人帮我
Include below line. 包括以下行。
jQuery(function() { // document ready
var sideBarTop = $('#sticky').offset().top; // position top
var sideBarLeft = $('#sticky').offset().left //position left
jQuery(window).scroll(function(){ // scroll event
var windowTop = $(window).scrollTop(); // returns scroll from top
if(sideBarTop < windowTop) {
$('#sticky').css({position: 'fixed', top: -40}).fadeIn("slow");
}
else $('#sticky').css('position', 'static').fadeOut("slow");
setTimeout ( function() { $('#sticky').fadeIn("slow"); },1000);
});
});
This is a patch for your existing code and it is not a recommended fix for you problem. 这是您现有代码的补丁程序,不是针对您的问题的建议修复程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.