jquery-tree-manipulator

a depth-first walker for manipulating an arbitrary DOM tree

View the Project on GitHub weisjohn/jquery-tree-manipulator

install:

bower install jquery-tree-manipulator or download the jquery-tree-manipulator.js file

jquery-tree-manipulator works with jQuery >= 1.4.3.

example:

After visualizing the results of running npm shrinkwrap or
npm ls --jsonon a repo with something like jQuery-JSONView, we can wire-up the tree-manipulator and some buttons to toggle the visible depth of the structure:

$(function() { 
    $("#jsonview").treeManipulator({
        structure: "> ul > li",
        opened: ".collapser:contains('-')",
        closed: ".collapser:contains('+')"
    });

    $(".controls a").click(function(e) {
        var depth = $(this).data('depth');
        $("#jsonview")
            .treeManipulator('close', depth + 1)
            .treeManipulator('open', depth);
    });
});
1 2 3 4 5 6 7 8