Skip to content

Instantly share code, notes, and snippets.

@sampsonbryce
Created November 3, 2016 22:06
Show Gist options
  • Save sampsonbryce/5ce5472efee813f71717a44e9ddd1905 to your computer and use it in GitHub Desktop.
Save sampsonbryce/5ce5472efee813f71717a44e9ddd1905 to your computer and use it in GitHub Desktop.
// attach quicktree to jquery
(function($) {
$.fn.quicktree = function() {
function click(e) {
var a = $(this);
a.next('ul').children("li").toggle();
a.parent().parent().parent().find('.active').removeClass('active');
a.addClass('active');
e.preventDefault();
}
// Grab the LI's and iterate over them
$(this).find("li").each(function(ind) {
var t = $(this);
t.children("a").off('click').click(click);
t.children('ul').quicktree();
});
return this;
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment