شرح صفوف ومحتوى الفقرة
هناك طريقة اخري لإزالة ال node من ال Tree ولكن عن طريق ال parent :
- قم باختيار ال parent عن طريق document.getElementById("parentIDName")
- قم باختيار ال child الذي تريد حذفة من ال tree عن طريق document.getElementById("childIDName")
- ثم نستخدم دالة removeChild مثال removeChildparent.removeChild(child)
HTML
<!DOCTYPE html>
<html>
<body>
<div id="div1">
<p id="p1">This is a paragraph.</p>
<p id="p2">This is another paragraph.</p>
</div>
<script>
var parent = document.getElementById("div1");
var child = document.getElementById("p1");
parent.removeChild(child);
</script>
</body>
</html>