Last active
August 20, 2022 12:18
-
-
Save kudinovfedor/b2c6cf1b4e71404a5ceb66cafc77c4c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tabs('.fk-tabs', '.fk-tabs-list', '.fk-tab-item'); | |
/** | |
* Tabs | |
* | |
* @example | |
* tabs('.tabs', '.tabs-list', '.tab-item'); | |
* @param {(string|Object)} container - main container for tabs | |
* @param {(string|Object)} list - ul list for each tab item | |
* @param {(string|Object)} item - tab block for each li item | |
*/ | |
function tabs(container, list, item) { | |
var parent = $(container), menu = $(list), child = $(item); | |
menu.on('click', 'li:not(.is-active)', function () { | |
$(this) | |
.addClass('is-active').siblings().removeClass('is-active') | |
.closest(parent).find(child).removeClass('is-active').eq($(this).index()).addClass('is-active'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment