how to deselect all element in jquery?

user1542984 picture user1542984 · May 19, 2014 · Viewed 19.9k times · Source

I want to deselect (remove selected element ).I am using jstree in my demo .So I read the plugin api . http://www.jstree.com/api/#/?f=deselect_all([supress_event]). But it not deleselect the selected item. I follow the these steps 1) Click the "b" node.then "b" node is selected. 2) Then press "deselect" button but it not deselect the items.

$('#deselect').click(function(){

    alert('--')
    $('#tree').deselect_all(true)

})

http://jsfiddle.net/fuu94/150/

Answer

Manwal picture Manwal · May 19, 2014

Try this code:

$('#tree').jstree("deselect_all");

Insted of

$('#tree').deselect_all(true)

Here is Updated fiddle