Search code examples
jquerytreeviewhighlighting

jquery treeview highlight only current item


Need a little help: I'm using jquery treeview plugin (this one: http://bassistance.de/jquery-plugins/jquery-plugin-treeview/). And I'd like to do highlighting the current item. I'm doing it this way:

CSS:

.filetree li .clicked {
    font-weight: bold;
}

And JS code:

$('li').live('click', function(event){
    event.stopPropagation();
    console.log(this.id);
    $('.clicked').removeClass('clicked');
    $(this).addClass('clicked');
    return false;
});

Everything works fine, but all items are highlighted together with its child elements, and the root elements are not highlighted in a whole.

How can I make a highlighting of only current item? Thanks in advance!


Solution

  • Ok, the right way is:

     $(event.target).addClass('clicked');
    

    instead of

     $(this).addClass('clicked');