0

これはほとんどの人にとって簡単なことだと思いますが、私はこの概念を学ぶのに苦労しています. 少しだけ助けが必要です。何が起こっているのかを説明するのに十分なコメントをしました。ありがとう!

//tabNavItem is an anchor link
$(tabNavItem).on("click", function(e){
    var currSlide = $(this).attr("rel");
    console.log(currSlide); // right here the value is equal to the rel of the link i click. this is correct!                   
    slideAnimation(); // i tried slideAnimation.call(currSlide) but got nothing and i tried slideAnimation(currSlide) and got 1 every time
    e.preventDefault();

});

function slideAnimation(){

    allTabs.hide();
    $(".active").removeClass("active");
    $("#" + currSlide).show();                          
    $("." + tabNavClass + " a[rel=" + currSlide + "]").addClass('active');          

    console.log(currSlide); //right now this equals 1, the rel of the first item.

};
4

3 に答える 3

1
//Add an argument here
function slideAnimation(item){
    allTabs.hide();
    $(".active").removeClass("active");
    $("#" + item).show();                          
    $("." + tabNavClass + " a[rel=" + currSlide + "]").addClass('active');          
};

//then call it like this 
$(tabNavItem).on("click", function(e){
    var currSlide = $(this).attr("rel");
    slideAnimation(currSlide);
    e.preventDefault();
});
于 2013-04-11T03:31:07.687 に答える