Skip to content

Instantly share code, notes, and snippets.

@karloscarweber
Created December 13, 2012 17:47
Show Gist options
  • Save karloscarweber/4278245 to your computer and use it in GitHub Desktop.
Save karloscarweber/4278245 to your computer and use it in GitHub Desktop.
A jQuery panel switcher. It alternates between different panelSlides
<div class="panel-container">
<a class="panelSwitch">
<h5>button</h5>
</a><!-- End of .panelSwitch -->
<div style="" class="panelBoard">
<!-- Fill me with any content -->
</div><!-- End of .panelBoard -->
<a class="panelSwitch">
<h5>button</h5>
</a><!-- End of .panelSwitch -->
<div style="" class="panelBoard">
<!-- Fill me with any content -->
</div><!-- End of .panelBoard -->
<a class="panelSwitch">
<h5>button</h5>
</a><!-- End of .panelSwitch -->
<div style="" class="panelBoard">
<!-- Fill me with any content -->
</div><!-- End of .panelBoard -->
<a class="panelSwitch">
<h5>button</h5>
</a><!-- End of .panelSwitch -->
<div style="" class="panelBoard">
<!-- Fill me with any content -->
</div><!-- End of .panelBoard -->
<a class="panelSwitch">
<h5>button</h5>
</a><!-- End of .panelSwitch -->
<div style="" class="panelBoard">
<!-- Fill me with any content -->
</div><!-- End of .panelBoard -->
<a class="panelSwitch">
<h5>button</h5>
</a><!-- End of .panelSwitch -->
<div style="" class="panelBoard">
<!-- Fill me with any content -->
</div><!-- End of .panelBoard -->
</div>
$(".panelSwitch").click(function() {
var state = $(this).next().css("display");
if (state == 'none') {
// If I am hidden!
// Remove active state and Slide up everyone.
$(".panelSwitch + .panelBoard").slideUp();
//and slide down my content
$(this).next().slideDown();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment