Skip to content

Instantly share code, notes, and snippets.

@githiro
Created June 13, 2013 00:12
Show Gist options
  • Select an option

  • Save githiro/5770228 to your computer and use it in GitHub Desktop.

Select an option

Save githiro/5770228 to your computer and use it in GitHub Desktop.
JS, HTML: Basic Tab UI
//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