문제

$(document).ready(function() {
    var activeTab = $('#tabs menu.active');
    var prevTab = activeTab.closest('.menu').prev();
    var nextTab = activeTab.closest('.menu').next();
    prevTab.addClass('prev');
    nextTab.addClass('next');

});

http://jsfiddle.net/qS4LN/

It doesn't seem to work, what am I doing wrong? I need to addClass prev and next to the tabs around the active tab.

도움이 되었습니까?

해결책

You're missing the first period on your selector. Your code is:

var activeTab = $('#tabs menu.active');

menu is a class and needs it's own period. Change the code to:

var activeTab = $('#tabs .menu.active');

다른 팁

updated jsfiddle

$(document).ready(function() {
    var activeTab = $('#tabs ul.menu.active');
    var prevTab = activeTab.closest('.menu').prev();
    var nextTab = activeTab.closest('.menu').next();
    prevTab.addClass('prev');
    nextTab.addClass('next');

});

You are missing a dot on 2nd line selector, change var activeTab = $('#tabs menu.active'); to var activeTab = $('#tabs ul.menu.active');

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top