标签:char sibling child lse document tno class func span
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>demo</title> </head> <body> <div class="tempDiv"></div> <div class="tempDiv"></div> <div class="tempDiv"></div> <div class="tempDiv"></div> <div class="tempDiv"></div> <div class="tempDiv"></div> </body> </html>
function removeChild() { var child= document.getElementsByClassName("tempDiv"); child.removeNode = []; if (child.length != undefined) { var len = child.length; for (var i = 0; i < len; i++) { child.removeNode.push({ parent: child[i].parentNode, inner: child[i].outerHTML, next: child[i].nextSibling }); } for (var i = 0; i < len; i++){ child[0].parentNode.removeChild(child[0]); } } else { child.removeNode.push({ parent: child.parentNode, inner: child.outerHTML, next: child.nextSibling }); child.parentNode.removeChild(child); } }
标签:char sibling child lse document tno class func span
原文地址:https://www.cnblogs.com/xxySsm/p/11758759.html