Delete all nodes in jsTree

Jeff Dege picture Jeff Dege · Jun 9, 2011 · Viewed 20.6k times · Source

Is there a way to clear out all nodes from a jsTree that's faster than walking through all the nodes deleting them one-by-one?

Answer

Brad picture Brad · Jul 13, 2011

The simplest way I have found is to simply call .empty on the div containing the tree.

$('#tree').empty();

You might choose to use a more specific selector as a parameter for empty(), but this works fine for me.