我试图在向下滚动事件时隐藏#header,然后在向上滚动页面时重新出现。
页面链接:- http://elementsmart.com/product-category/jewellery/
我使用的 javascript 代码
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript">
$('#primary').scroll(function(){
if($(this).scrollTop() > 300) $('#header').fadeOut('slow');
if($(this).scrollTop() < 300) $('#header').fadeIn('slow');
});
</script>
CSS
#header-container {
position:fixed !important;
margin-left:1.6% !important;
z-index:999 !important;
}
当有人滚动主要需要隐藏标题时。
在 jsfiddle 上尝试过似乎工作完美,但现在在页面上显示。
有人可以指导吗?