Jquery tree tree highlighted

I implement jQueryFileTree ( http://www.abeautifulsite.net/jquery-file-tree/ ) as a file browser and would like each file or directory to click on the user to stay highlighted, I know that this can be done with using simple JavaScript or CSS, but I don’t understand the source code enough to know how and where to implement the selection. Can someone point me in the right direction?

+4
source share
3 answers

Well, you can click with the handler clickand add a class using addClass.

$('.thing-i-will-click-on').click(function() {
  $(this).addClass('selected');
});

You can also delete a class using a similar method.

$('.selected').removeClass('selected');

Combining these two things should give you the desired result.

+1

, !

jqueryFileTree.js 80 :

h($(this).attr('rel'));

h($(this));

, . () .fileTree, :

file.attr('rel');

, (), . ( CSS, , )

$(".selected").removeClass('selected');
file.addClass('selected');
+1
$('#your_filelist_id').fileTree({
  root: '/',
  script: '/connectors/jqueryFileTree.php'
}, function(file) {
  var flist = $('#your_filelist_id a[rel="' + file + '"]');
  if(flist.hasClass('selected')) {
    flist.removeClass('selected');
  }
  else {
    flist.addClass('selected');
  }
});
0
source

All Articles