Вопрос

$(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