Search⌘ K

Get Started with the DOM in JavaScript

Let's discover DOM objects properties and methods that you can manipulate with JavaScript.

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 ...