JavaScript and the DOM

Document Object Model

The Document Object Model, commonly referred to as the DOM', is the term for elements in an HTML file. Elements are any HTML code denoted by HTML tags, like <div>, <a>, or <p>. Let's use JavaScript to interact with the DOM.

We can select an HTML element with JavaScript by selecting its class attribute, like this:

var header = document.getElementsByClassName('example-class-name');

This would find an element like this in the HTML:

<div class='example-class-name'> ... </div>
Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.