Created
August 14, 2014 15:23
-
-
Save corysimmons/bc02e50d0c8cc3f5b06c to your computer and use it in GitHub Desktop.
jQuery Tabs without 10k characters
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
<nav class="tabs-nav"> | |
<button data-target-tab="tab-1">Area Code</button> | |
<button data-target-tab="tab-2">Location</button> | |
<button data-target-tab="tab-3">Toll Free</button> | |
</nav> | |
<div class="tab-content" data-tab="tab-1"> | |
area code | |
</div> | |
<div class="tab-content" data-tab="tab-2"> | |
location | |
</div> | |
<div class="tab-content" data-tab="tab-3"> | |
toll free | |
</div> |
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
$('.tabs-nav button').click(function() { | |
$('.tab-content').hide(); | |
$('[data-tab="' + $(this).data('targetTab') + '"').show(); | |
}); |
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
.tab-content | |
display: none | |
&:first-of-type | |
display: block |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment