要在ul中添加li元素,我已经完成了这个......
var ul = document.getElementById('ul-id');
var li= document.createElement("li");
li.appendChild("some text here");
ul.appendChild(li);
但它在我的控制台中给出错误。我没有得到这个代码的问题。任何帮助将不胜感激。
错误:
Error: NotFoundError: DOM Exception 8
code: 8
message: "NotFoundError: DOM Exception 8"
name: "NotFoundError"
stack: "Error: An attempt was made to reference a Node in a context where it does not exist.
谢谢!