asked 60.3k views
2 votes
All steps in this challenge activity require calling a document method to search the DOM. Write the JavaScript to assign listNodes with all elements with a class name of 'language-item'.

1 Answer

3 votes

Final answer:

To assign listNodes with elements having the class name 'language-item', use the getElementsByClassName() method.

Step-by-step explanation:

In order to assign listNodes with all elements having a class name of 'language-item', we need to use the JavaScript method getElementsByClassName(). This method returns a live HTMLCollection of elements that have the specified class name. Here's an example:

var listNodes = document.getElementsByClassName('language-item');

In this example, listNodes will contain all the elements with the class name 'language-item' in the document.

answered
User BertC
by
8.4k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.