1

ここで JQuery ウェイポイントに少し問題があります。私の1ページサイトでの自動スクロールナビゲーションに使用しています:

signaturestories.eu

スクロール ホイールを使用すると正常に動作します。特定の要素が画面の上部に到達するたびに、ナビゲーション アイテムの色を変更する必要があります。問題は、サインアップ --> について --> サインアップを押したときに、3 回目は色が変わらないことです。

script.js:

    $('a[href^="#"]').bind('click.smoothscroll',function (e) {
        e.preventDefault();

        var target = this.hash,
        $target = $(target);

        $('html, body').stop().animate({
            'scrollTop': $target.offset().top-40
        }, 900, 'swing', function () {
            window.location.hash = target;
        });
    });


var currentMenuObject = '';

$('#wrapper').waypoint(function() {
    $(currentMenuObject).css('color', '#f2e0bd');
    currentMenuObject = '#top';
    $(currentMenuObject).css('color', 'black');
}, { offset: '55'});

$('#introarticle').waypoint(function() {
    $(currentMenuObject).css('color', '#f2e0bd');
    currentMenuObject = '#top';
    $(currentMenuObject).css('color', 'black');
}, { offset: '55'});

$('#signsection').waypoint(function() {
    $(currentMenuObject).css('color', '#f2e0bd');
    currentMenuObject = '#signup';
    $(currentMenuObject).css('color', 'black');
}, { offset: '55'});

$('#storyarticle').waypoint(function() {
    $(currentMenuObject).css('color', '#f2e0bd');
    currentMenuObject = '#about';
    $(currentMenuObject).css('color', 'black');
}, { offset: '55'});
4

1 に答える 1

2

ページに jquery を追加する前に、このビットを呼び出しています。

$(document).ready(function(){
    //jQuery code goes here and will be executed as soon as the page has finished loading
});    

これによりエラーがスローされ、$ is not a functionコードの実行が停止します。

于 2013-05-20T10:27:03.350 に答える