在向下滚动事件wordpress上隐藏div

时间:2013-06-28 07:37:13

标签: javascript jquery wordpress woocommerce

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

有人可以指导吗?

1 个答案:

答案 0 :(得分:0)

差不多完成了,改变了

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

$(window).scroll(function(){

还用

包装你的代码
$(function(){
    //your code here
});
相关问题