如何使节点成为可选择的(添加活动类)。

时间:2014-05-05 10:32:06

标签: javascript jquery jstree

您能否告诉我如何自动选择节点(添加活动类)?当用户选择任何节点时,它变为可选择,换句话说它变为蓝色。 但现在当我点击子按钮时,我得到了" b"的孩子,但它不可选。我们可以制作" b"可选择?当用户点击"子按钮"时,我们可以使用下一个和上一个按钮来移动此活动类吗?当用户单击下一个和上一个按钮时,它会显示在顶部和底部。 http://jsfiddle.net/fuu94/44/

$('#child').click(function () {
for(i in $('#tree').jstree(true).get_node('b').children){    alert($('#tree').jstree(true).get_text($('#tree').jstree(true).get_node('b').children[i.toString()]));
}
});

2 个答案:

答案 0 :(得分:0)

要在下次设置未设置的活动并预先点击:

  $('#next').click(function () {
    if($('.jstree-clicked').closest('li').next().length)
        $('.jstree-clicked').removeClass('jstree-clicked').closest('li').next().find('a:eq(0)').addClass('jstree-clicked')
  });
  $('#pre').click(function () {
     if($('.jstree-clicked').closest('li').prev().length)
        $('.jstree-clicked').removeClass('jstree-clicked').closest('li').prev().find('a:eq(0)').addClass('jstree-clicked')
  });

<强> Demo

答案 1 :(得分:0)

您可以使用select_node(节点)使'b'可选。来自http://jsfiddle.net/23NAG

http://www.jstree.com/docs/interaction/ $('#tree').jstree(true) .select_node('b');

下一个和上一个可以使用相同的select_node使用子ID。