【中文标题】我的javascript代码有啥问题-根据条件(存在另一个元素)删除HTML元素-初学者【英文标题】:What is the problem in my javascript code - delete an HTML element based on a condition (presence of another element) - beginner我的javascript代码有什么问题-根据条件(存在另一个元素)删除HTML元素-初学者【发布时间】:2019-10-16 04:11:33【问题描述】:
function removeElement(id)
var elem = document.getElementById(id);
var dad = elem.parentNode.parentNode.prentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
dad.removeChild(dad.firstChild);
function destroyLoop()
var i = O;
while (i < 100)
removeElement("svgIcon svgIcon--star svgIcon--15px");
i++;
destroyLoop();
function removeElement(id)
var elem = document.getElementsByClassName(id)[0].closest("article");
var dad = elem.parentNode;
dad.removeChild(elem);
function destroyLoop()
var i = 0;
while (i < 100)
removeElement("svgIcon svgIcon--star svgIcon--15px");
i++;
destroyLoop();