1
我是新來的jQuery和JavaScript。我正在嘗試創建單頁網站。導航固定在頂部。在單個頁面的新「部分」中,我希望導航能夠顯示導航中當前要顯示的部分以及要突出顯示的部分。導航鏈接更改滾動位置(單頁網站)
我設法用scroll()做了一些工作,但只有當變量'top'大於0時才起作用。我知道這可能真的很愚蠢我做錯了,但我是新來的所以我希望這不會打擾你。
$(document).scroll(function() {
var top = $(document).scrollTop();
if (200 > top > 0)
$(".navLinkTop").css("border-bottom", "5px solid #fff568");
else
$(".navLinkTop").css("border-bottom", "none");
if (400 > top > 200)
$(".navLinkAbout").css("border-bottom", "5px solid #fff568");
else
$(".navLinkAbout").css("border-bottom", "none");
if (400 > top > 0)
$(".navLinkWork").css("border-bottom", "5px solid #fff568");
else
$(".navLinkWork").css("border-bottom", "none");
if (400 > top > 0)
$(".navLinkContact").css("border-bottom", "5px solid #fff568");
else
$(".navLinkContact").css("border-bottom", "none");
});
唉唉,我看,這作品!非常感謝!我會盡快接受答案。謝謝。 – user1375823 2013-03-09 14:38:40