jQuery中的Alert()调用没有显示,在JsTree中调用

我在这段代码中看不到警报。 这可能是一个错字,因为我跟踪代码正在执行,我收到正确的“nodeInfo”警报只是没有出现。

function loadTree(jsonData){ var treeInfo = attachTree(stageTreeData(getJson(jsonData))); $("#apple_tree").jstree({ "json_data": {"data": treeInfo}, "plugins" : [ "themes", "json_data", "ui" ] }).bind("select_node.jstree", function (event, data) { // `data.rslt.obj` is the jquery extended node that was clicked var nodeInfo = data.rslt.obj.attr("id"); alert(nodeInfo); }); } 

感谢您的帮助!

编辑#1更改了代码结构:

 function loadTree(jsonData){ var treeInfo = attachTree(stageTreeData(getJson(jsonData))); $("#apple_tree").jstree({ "json_data": {"data": treeInfo}, "plugins" : [ "themes", "json_data", "ui" ] }); $("#apple_tree").bind("select_node.jstree", function (event, data) { // `data.rslt.obj` is the jquery extended node that was clicked var nodeInfo = data.rslt.obj.attr("id"); alert(nodeInfo); }); } 

仍然没有运气警报()出现。