Search⌘ K

Get Started with the DOM in JavaScript

Explore how to interact with the DOM in JavaScript by accessing the document object, navigating child nodes, understanding node types, and using parentNode. This lesson provides foundational skills to manipulate web page elements programmatically and understand their structure.

Access the DOM with the document variable

When a JavaScript program runs in the context of a web browser, it can access the root of the DOM using the variable document. This variable matches the <html> element. document is an object that has head and body properties which allow access to the <head> and <body> elements of the page.

Discover a node’s type

Each object has a property called nodeType which indicates its type. The value of this property is ...