您能告诉我为什么删除功能不起作用吗?我正在从菜单选项中删除代码。 http://jsfiddle.net/fuu94/136/
$('#remove').click(function(){
alert('dd') ;
$("#b-a-1").remove();
$('#tree').jstree(true).delete_node("#b-a-1");
})
最佳答案
您需要使用双反斜杠\\
转义特殊字符-
。来自docs :
To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\
$("#b\\-a\\-1").remove();
使用 delete_node
方法删除节点时,无需指定 #
,因为它始终将您的 obj
视为独特的元素:
$("#tree").jstree(true).delete_node('b-a-1') ;
<强> Updated Fiddle
关于javascript - 为什么删除功能不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23693516/