Home  >  Article  >  Web Front-end  >  How to delete child nodes created by javascript_javascript skills

How to delete child nodes created by javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:58:051179browse

The example in this article describes the method of deleting child nodes created by javascript. Share it with everyone for your reference. The details are as follows:

I don’t know how to delete the node created by js. . . It took a lot of time

for(var i = 0; i < jsonList.length; i++ ){
  var li_button = document.createElement("li");
  li_button.className = "button";
  var li_button_a = document.createElement("a");
  li_button_a.id = jsonList[i]._id;
  var li_button_text = document.createTextNode(jsonList[i].projectName);
  li_button_a.appendChild(li_button_text);
  li_button.appendChild(li_button_a);  
  ul_level2.appendChild(li_button);
}

Later I found out that the node is actually

ul_level2.innerHTML = '';InnerHTML ='' content, as long as it is set to empty, the child nodes can be cleared.

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn