Last active
January 8, 2019 11:19
-
-
Save atomrli/04a4241df62fa5c326085a6b00d4d566 to your computer and use it in GitHub Desktop.
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
| <div class="container"> | |
| <div class="tabs-items"> | |
| <div class="tabs-item"> | |
| 1 tab content | |
| </div> | |
| <div class="tabs-item"> | |
| 2 tab content | |
| </div> | |
| <div class="tabs-item"> | |
| 3 tab content | |
| </div> | |
| </div> | |
| <nav class="tabs-nav"> | |
| <a href="#">1 tab</a> | |
| <a href="#">2 tab</a> | |
| <a href="#">3 tab</a> | |
| </nav> | |
| </div> | |
| <script> | |
| $('nav.tabs-nav').on('click', 'a:not(.active)', function(e) { | |
| e.preventDefault(); | |
| $(this) | |
| .addClass('active').siblings().removeClass('active') | |
| .closest('.container').find('.tabs-items').find('.tabs__item').removeClass('active').eq($(this).index()).addClass('active'); | |
| }); | |
| $('.tabs-nav').each(function() { | |
| $(this).find('a:first').addClass('active') | |
| }); | |
| $('.tabs-items').each(function() { | |
| $(this).find('.tabs__item:first').addClass('active') | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment