1

我试图在向下滚动事件时隐藏#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 上尝试过似乎工作完美,但现在在页面上显示。

有人可以指导吗?

4

1 回答 1

0

差不多了,换

$('#primary').scroll(function(){

$(window).scroll(function(){

还用

$(function(){
    //your code here
});
于 2013-06-28T07:50:43.827 回答