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');
Вопрос
$(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');
});
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');