我正在使用JQuery TreeView插件,我想知道如何突出显示/识别最后选择的节点。有没有人碰到过这个?
发布于 2009-12-01 22:46:08
由于我没有收到Alexander Corotchi对我的问题的回答,我最终实现了我自己的解决方案。我相信有更简单的解决方案,但它就在这里。
$(treeView).treeview({
/* Initialize TreeView */
})
$(treeView).click(function onTreeViewClick(sender) {
var clickedElement = $(sender.target);
if (clickedElement.hasClass('hover')) {
//Find all selected nodes and deselect them.
var treeView = $(document.getElementById('usxTreeView'));
$.each(treeView.find(".selectedNode"), function(index, node) {
$(node).removeClass('selectedNode');
});
//Select newly selected node
clickedElement.addClass('selectedNode');
//Get the node Id for the parent LI
var parents = clickedElement.parent('li');
//This can then be used to identify the node.
selectedTreeNodeId = parents[0].id;
}
});发布于 2009-12-01 00:33:13
$('ul.yourclassselected li:last-child').addClass( 'highlight class' );https://stackoverflow.com/questions/1820843
复制相似问题