Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
我正在使用下面的 script-let 将节点添加到 dhtmlx 树。
我试图使用 getSelectedItemId() 从 DHTMLX tree.And 获取 id 我遇到了这个错误。
<script>
var xmlDoc
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
xmlDoc = this;
}
};
xhttp.open("GET", "data/treeStruct.xml", true);
xhttp.send();
var myTree;
function append(id){
var x;
var ed1=document.getElementById('ed1').value;
//alert(id);
xmlDoc = xmlDoc.responseXML;
var newEle = xmlDoc.createElement(id);
newEle.appendChild(ed1);
document.getElementsByTagName("tree")[0].appendChild(newEle);
}
</script>
DHTMLX树有自己的API来添加节点。您无需直接与 HTML 互动。只需使用像 next
这样的代码
//to add a new item to the tree
tree.insertNewChild(0,1,"tree")
tree.insertNewChild(1,2,"child")
//parent id, id, text
此外,检查代码段 http://snippet.dhtmlx.com/320fe781a
我正在使用下面的 script-let 将节点添加到 dhtmlx 树。 我试图使用 getSelectedItemId() 从 DHTMLX tree.And 获取 id 我遇到了这个错误。
<script>
var xmlDoc
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
xmlDoc = this;
}
};
xhttp.open("GET", "data/treeStruct.xml", true);
xhttp.send();
var myTree;
function append(id){
var x;
var ed1=document.getElementById('ed1').value;
//alert(id);
xmlDoc = xmlDoc.responseXML;
var newEle = xmlDoc.createElement(id);
newEle.appendChild(ed1);
document.getElementsByTagName("tree")[0].appendChild(newEle);
}
</script>
DHTMLX树有自己的API来添加节点。您无需直接与 HTML 互动。只需使用像 next
这样的代码//to add a new item to the tree
tree.insertNewChild(0,1,"tree")
tree.insertNewChild(1,2,"child")
//parent id, id, text
此外,检查代码段 http://snippet.dhtmlx.com/320fe781a