Last active
August 15, 2016 19:44
-
-
Save moladukes/3a6b50d2c8630ffa16f921ebd97a5c6a to your computer and use it in GitHub Desktop.
Simple JQuery Tabs
This file contains hidden or 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
<!-- CSS --> | |
<style> | |
.tab-content { | |
display: none; | |
} | |
.tab-content.active { | |
display: block; | |
} | |
</style> | |
<!-- JS // Requires Jquery --> | |
<script> | |
$('.tab').on('click', function(evt) { | |
evt.preventDefault(); | |
$(this).toggleClass('active'); | |
var sel = this.getAttribute('data-toggle-target'); | |
$('.tab-content').removeClass('active').filter(sel).addClass('active'); | |
}); | |
</script> | |
<!-- Tabs --> | |
<a href="#" class="tab active" data-toggle-target=".tab-content-1">Tab 1</a> | |
<a href="#" class="tab" data-toggle-target=".tab-content-2">Tab 2</a> | |
<!-- Content --> | |
<div class="tab-content tab-content-1 active"> | |
<h1>Tab Content 1</h1> | |
</div> | |
<div class="tab-content tab-content-2"> | |
<h1>Tab Content 2</h1> | |
</div> | |
<!-- Fin --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment