我確定這對大多數人來說很簡單,但我很努力學習這個概念。我只需要一點幫助。我已經評論足以解釋發生了什麼。謝謝!我需要將一個變量傳遞給我的函數
//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.
};
謝謝!我在一個點上嘗試過每一個,猜想我只是沒有在同一時間做。感謝幫助我!我會盡快接受! – heyjohnmurray 2013-04-11 03:31:32