滚动到特定位置后隐藏固定内容?

时间:2012-09-18 18:41:30

标签: javascript css wordpress javascript-events css-float

我使用此(https://github.com/cheald/floatingFixed)javascript在我的网站上创建社交分享栏。它工作得很好,但我不想在它滚动到页脚页面时显示它。这该怎么做?这是我网站的http://thedripple.com/1384/lg-optimus-g-launch-price/

页面之一

1 个答案:

答案 0 :(得分:2)

非常直接,因为你已经包含了jQuery:

$(window).scroll(function() { //when scrolled
    var flt = $(".floater");
    var offset = flt.offset().top + flt.height(); //get the current offset of the floater
    var footertop = $("#footer").offset().top; //and the footer's top offset
    if(offset > footertop) { //if you scrolled past the footer
        flt.hide(); //hide the sharing tab
    }
    else {
        flt.show(); //show it
    }
});