Select an HTML Element with document.querySelector

Share this video with your friends

Send Tweet

You can use document.querySelector to fetch elements from your HTML document.

In this lesson, we pass an Id to querySelector indicated with a #.

document.querySelector('#movie-2').

querySelector will return the first element that it matched.