I am learning the basics of javascript. now it DOM and i am stuck here, How can i remove a parent node with all its chldren. eg say i have the html code like this.
<ul id ="parent">
<li>Hi</li>
<li>How</li>
<li>Are</li>
<li>You</li>
</ul>
i wand to delete the <ul> element with all its child <li> nodes. I tried it to do like this document.getElementById('parent').removeNode(true); but its not working. Can anyone help me here. ?
You need to get a handle to the
ulelement then ask its parent element to delete it by passing theulhandle the parent’sremoveChildmethod.This is how you would do it without the jQuery framework:
Of course if you used jQuery it would be simple like this: