Skip to content

Instantly share code, notes, and snippets.

@kaliaparijat
Created August 23, 2012 23:16
Show Gist options
  • Save kaliaparijat/3443279 to your computer and use it in GitHub Desktop.
Save kaliaparijat/3443279 to your computer and use it in GitHub Desktop.
jQuery accordion and jQuery tabbed browser: Both are separate libraries,included together for demonstrative purposes
<script type = "text/javascript" charset = "utf-8">
$(document).ready(accordion() ) ;
function accordion()
{
$('#critical_reading').show();
$('.head').click(function(e) { // binding an event handler to all elements that belong to the class head, in this case hyper links
$(this).closest('li').find('.topics').slideToggle()
$(this).closest('li').next().find('.topics').slideUp();
$(this).closest('li').prev().find('.topics').slideUp();
})
}
<script type = "text/javascript" src = "jquery.min.js" charset="utf-8"></script>
<script type = "text/javascript" charset = "utf-8">
$(document).ready(setup())
function setup()
{
$('#tabbed .tabs').hide();
$('#tabbed .tabs:first').show();
$('#tabbed a').click(showSelectTab);(this).animate({'margin-top':'5px'}) } ) ;
}
function showSelectTab()
{
var tab = $(this).attr('href');
$(tab).addClass('selected');
$('#tabbed .tabs').hide();
$(tab).show();
}
</script>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment