kusanagi kusanagi - 4 months ago 9
Javascript Question

jquery Treeview highlighting selected item

i read docs


http://docs.jquery.com/Plugins/Treeview/treeview#options


also googled, but nothing found easy and good solution, how to highlighting the selected item. i use span so not redirect but nothing selected

Answer

You can select li items in the tree and add event listeners to them, like this:

$('#browser li.file').bind('click', function() {
  //clear all clicked items if any
  $('.clicked').removeClass('clicked');
  //set this clicked
  $(this).addClass('clicked');
})

Inside handler function 'this' word points to the clicked item. Or if by 'selecting' you mean something else, you can also listen desired event type like in example.

$('#browser li.file').bind('mouseover', function() {
 ... your code ...
})