Skip to content

Instantly share code, notes, and snippets.

@jesseshowalter
Last active December 26, 2015 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesseshowalter/7224531 to your computer and use it in GitHub Desktop.
Save jesseshowalter/7224531 to your computer and use it in GitHub Desktop.
My first Gist, learning how to use this so I can embed code on my site
<nav>
<a class="brand" href="../../index.html"><h1>Jesse Showalter</h1></a>
<span>Jesse Showalter - EST.1984</span>
<ul>
<li><a href="../../about.html">Info</a></li>
<li><a href="../../articles/index.html">Articles</a></li>
<li><a href="../../contact.html">Contact</a></li>
</ul>
</nav>
// For the tags content drawer
$(document).ready(function(){
$('.content-drawer').hide();
$('.tab').click(function() {
var $this = $(this);
var target = $(this.rel);
$this.closest('li').addClass('active focus');
// Add the classes to the closest li of the clicked anchor
$('.tab').not($this).closest('li').removeClass('active focus');
// Remove the classes for the non-clicked items
$('.content-drawer').not(target).slideUp();
// Slideup the other contents
target.delay(200).slideToggle();
// Toggle the current content
if (target.is(':visible')) {
// Only if the target is visible remove the active class
$this.closest('li').removeClass('active');
}
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment