Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrian Patterson
19,588 PointsI am a bit confused
I have a few questions about this function.
listUL.addEventListener('click', (event) => {
//this saying the if the html element is button
if (event.target.tagName == 'BUTTON') {
//if the class name is 'remove'.
if (event.target.className == 'remove'){
//I am unsure what this means.
let li = event.target.parentNode;
//I am unsure what this means.
let ul = li.parentNode;
//this removes the child
ul.removeChild(li);
}
1 Answer
Steven Parker
231,270 PointsDoes this clear it up?
let li = event.target.parentNode;
get the list item (li) element that this button is in
let ul = li.parentNode;
get the unordered list (ul) that the list item is in
Brian Patterson
19,588 PointsBrian Patterson
19,588 PointsBrilliant Steven. Can give me any tips on how best to learn about the DOM.
Steven Parker
231,270 PointsSteven Parker
231,270 PointsI really enjoyed the course you're taking right now. There's also DOM Scripting By Example.