Skip to content

Instantly share code, notes, and snippets.

@benhoskings
Created February 9, 2009 06:47
Show Gist options
  • Save benhoskings/60684 to your computer and use it in GitHub Desktop.
Save benhoskings/60684 to your computer and use it in GitHub Desktop.
var handle_list_link = function() {
// Get the currently displayed element in the list, if there is one
var cur = $(this).parents('ul.list:first').children('li.cur');
var cur_clicked = $(this).is('.cur');
// If there is a current element, hide it
if (cur.length != 0) {
cur.removeClass('cur')
.children('a.cur').removeClass('cur')
.siblings('.data:visible').hide('drop', {direction: 'down'});
}
// Show the element that was clicked, unless it was the current element
if (!cur_clicked) {
$(this).addClass('cur')
.parents('li:first').addClass('cur')
.children('.data').fadeIn();
}
};
$(function() {
$('ul.list a.trigger').click(handle_list_link);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment