Created
November 9, 2012 18:21
-
-
Save hsquareweb/4047330 to your computer and use it in GitHub Desktop.
JavaScript: Simple Content Slider
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
| <script type="text/javascript"> | |
| $('#tabs div').first().attr('class', 'current'); | |
| $('#tabs div').each(function(i) { | |
| i = i + 1; | |
| $(this).attr('id', 'tab-' + i); | |
| if(i !== $('#tabs div').size()) { | |
| $(this).append('<button class="tabPagination" rel="tab-' + (i + 1) + '">Next</button>'); | |
| } | |
| if(i !== 1) { | |
| $(this).append('<button class="tabPagination" rel="tab-' + (i - 1) + '">Previous</button>'); | |
| } | |
| }); | |
| $('#tabs div[class!="current"]').hide(); | |
| $('.tabPagination').live('click', function() { | |
| $('.current').removeAttr('class'); | |
| $('#tabs div[class!="current"]').hide(); | |
| $('#' + $(this).attr('rel')).show(); | |
| }); | |
| </script> | |
| <div id="tabs"> | |
| <div>First</div> | |
| <div>Second</div> | |
| <div>Third</div> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment