Skip to content

Instantly share code, notes, and snippets.

@shohagbhuiyan
Created November 12, 2017 23:37
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 shohagbhuiyan/83994d90674c7970471dfa06a92f52f1 to your computer and use it in GitHub Desktop.
Save shohagbhuiyan/83994d90674c7970471dfa06a92f52f1 to your computer and use it in GitHub Desktop.
jQuery Tabs using CSS
/*Note: add class "tabSet1" or "tabSet2" after ul.tabs and tab-content */
function tab(x) {
var a = $('ul.tabs.' + x + ' ' + 'li');
a.click(function () {
var tab_id = $(this).attr('data-tab');
a.removeClass('active');
$('.tab-content.' + x).removeClass('active');
$(this).addClass('active');
$("#" + tab_id).addClass('active');
});
}
tab('tabSet1');
tab('tabSet2');
/* Follow the link to see in pactice
https://jsfiddle.net/shohagbhuiyan/zfL4osw0/1/
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment