Now that you are more comfortable with some programming fundamentals, we can take a deeper dive into the programming interface the browser provides to control the DOM using JavaScript.

Working with element nodes

Each element on your HTML page has an associated element node in the Document Object Model (DOM). The DOM can be accessed using JavaScript through the document object. document behaves like any other JavaScript object, and has many different properties and methods that are useful in accessing nodes in the DOM.

document.querySelector(selector)

Let’s start with an example:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy