Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Interacting with the DOM!
You have completed Interacting with the DOM!
Preview
Just as we can select all child elements of a node we can also select an element's parent with the parentNode property.
Further Reading:
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
In this example, the list item is
the parent of the remove button.
0:00
Just as we're able to select an element's
children, we can also select its parent.
0:03
We'll use the remove method
you used in JavaScript
0:08
and the DOM to remove
elements from the DOM.
0:12
You'll need the call remove
on the button's parent.
0:16
But there's a problem,
you don't have a reference to the parent.
0:18
You'll need to traverse
to the parent node.
0:22
To get a reference to an element's parent
node, you can use the parentNode property.
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up