From the course: JavaScript: Enhancing the DOM

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Solution: Element hunter

Solution: Element hunter

(upbeat rhythmic music) - [Instructor] And here you can see the solution. For challenge one, I used getElementById to select the action button. For the second one, I got all the elements by class name info and looped over them and printed the results. Then for the third challenge, I got the elements by tag name, and again, looped over them to print the results. Then the fourth one, it was possibly slightly more challenging. Here I want to get all the spans with the class highlight, and that's what it did with querySelectorAll span.highlight. And here you can see the results. All of them are printed nicely. There are many ways to solve this challenge, and the key is understanding how to select and manipulate elements effectively. So if you've got the right answers, you most probably did it right. And that wraps up our module on selecting DOM elements. In our next module, we'll explore traversing the DOM, which is another essential skill in your web development toolkit.

Contents