Home > Web Front-end > JS Tutorial > body text

How to delete child nodes created by javascript_javascript skills

WBOY
Release: 2016-05-16 15:58:05
Original
1137 people have browsed it

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);
}

Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!