Skip to content

Instantly share code, notes, and snippets.

@joneff
Forked from RStankov/gist:179320
Created September 2, 2009 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save joneff/179708 to your computer and use it in GitHub Desktop.
Save joneff/179708 to your computer and use it in GitHub Desktop.
Tabs
<div class="tab-panel">
<nav class="tabs">
<ul>
<li href="#sect-1">tab 1</li>
<li href="#sect-2">tab 2</li>
<li href="#sect-3">tab 3</li>
</ul>
</nav>
<section id="sect-1"></section>
<section id="sect-2"></section>
<section id="sect-3"></section>
</div>
<script>
$$("nav.tabs li").each(function(tab) {
tab.observe("click", function(event) {
Event.stop(event);
tab.addClassName("selected").siblings().invoke("removeClassName", "selected");
var target = $(tab.href.substring(tab.href.indexOf("#") + 1));
if (target) {
target.show().siblings().slice(0).invoke("hide");
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment