【问题标题】:jQuery hide url on last sectionjQuery 在最后一部分隐藏 url
【发布时间】:2015-07-06 22:32:22
【问题描述】:

我尝试了很多解决方案,但仍然无法弄清楚如何去做。我使用 fullpage.js 并且有固定的页脚。 “Fullpage.js”让您创建一个包含部分的页面。您可以从 section1 滚动到 section2、section2 -> section3 等等......并且所有部分都有固定的页脚。我需要在最后一个部分(页面)隐藏页脚,但在所有其他部分显示。

<script type="text/javascript">
    var len = $('.section').length;
    $('.section').each(function(index, element) {
        if (index == len - 1) {
        $('#footer').hide();
        } else {
         $('#footer').show();
        }
    }
</script>

有人可以帮助我吗?如何在最后一部分隐藏#footer。在所有部分中显示,但当人们在最后一个部分滚动时隐藏。

最好的问候,谢谢

【问题讨论】:

  • footer 的长度是多少?所有部分都有一个页脚,还是每个部分都有自己的页脚?
  • 嘿,大约 50 像素。所有部分都有一个页脚。

标签: jquery hide footer fullpage.js


【解决方案1】:

您应该使用 Fullpage.js 事件来做到这一点:

//Get the last section index
//Add 1 because index starts from 0 in jquery
var lastIndex = $('.section').last().index() + 1;

$('#fullpage').fullpage({
    //... your options are here ...
    onLeave: function (index, direction) {
        if (index == lastIndex) {
            $('#footer').fadeIn();
        }
    },
    afterLoad: function(anchorLink, index) {
        if (index == lastIndex) {
            $('#footer').fadeOut();
        }
    }
});

所以假设你的页脚是 $('#footer'),当你离开或加载最后一个部分时它会淡入或淡出。

更多信息在这里:https://github.com/alvarotrigo/fullPage.js#onleave-index-nextindex-direction

【讨论】:

    猜你喜欢
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-06
    • 2016-06-05
    • 1970-01-01
    相关资源
    最近更新 更多