Skip to content

Instantly share code, notes, and snippets.

@pafnuty
Created March 14, 2014 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pafnuty/9543555 to your computer and use it in GitHub Desktop.
Save pafnuty/9543555 to your computer and use it in GitHub Desktop.
tabs + event
// Табы с генерацией события (на всякий случай)
$('body').on('click touch', 'ul.tabs li:not(.current):not(.disabled)', function(callback) {
thisTab = $(this); // Определяем переменную текущего таба
thisTab
.addClass('current') // добавляем класс текущему табу
.siblings().removeClass('current') // Удаляем класс у остальных табов в блоке
.parents('.tab-section') // Находим родительский блок
.find('.box').eq(thisTab.index()) // Находим нужный блок
.fadeIn(150, function () { // Показываем его
thisTab.trigger('tabClick'); // и генерируем событие tabClick
})
.siblings('.box').hide(); // Прячем остальные блоки с контентом
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment