JavaScriptJavaScript · Lesson 10

The DOM

Selecting, reading and changing elements.

Video tutorialTrack course · freeCodeCamp
Speed
Next lesson
Watch 00:00 · 1 checkpoints Watch on YouTube More on this topic
Transcript & captions
5/5

The DOM is the browser's object representation of your HTML. Use querySelector / querySelectorAll to grab elements, then change textContent, innerHTML, classList, style or attributes.

Try it yourself

Prefer textContent over innerHTML when inserting user data — innerHTML can execute injected markup.

Knowledge check

0/1 answered

Which is safer for inserting plain user text?