Created
June 13, 2013 00:12
-
-
Save githiro/5770228 to your computer and use it in GitHub Desktop.
JS, HTML: Basic Tab UI
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
| //html | |
| <div class="uiTabList clearfix"> | |
| <p class="nav"> | |
| <a href="javascript: void 0;" onclick="_self.changeTab(this);" class="active">Menu Title 1</a> | |
| <a href="javascript: void 0;" onclick="_self.changeTab(this);">Menu Title 2</a> | |
| </p> | |
| <div class="tabs"> | |
| <div class="tab active"> | |
| </div> | |
| <div class="tab"> | |
| </div> | |
| </div> | |
| </div> | |
| //JavaScript | |
| var _self = {};//global | |
| _self.changeTab = function(elem) | |
| { | |
| var $this = $(elem), | |
| $parent = $this.parent(), | |
| index = $parent.children().index(elem); | |
| $parent.children().removeClass("active"); | |
| $this.addClass("active"); | |
| $parent.next().children() | |
| .removeClass("active") | |
| .eq(index).addClass("active"); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment