Array
University of Oregon

DOM API

The Document Object

When an HTML document is loaded into a web browser, it becomes a document object.

The document object is the root node of the HTML document and the “owner” of all other nodes.

The DOM API

The document object provides properties and methods to access all node objects, from within JavaScript.

We’ve been using document.getElementByID() to select a DOM element and then processing its contents.

jQuery offers an API that is widely used for the same purpose. Now the DOM API has evolved along the same lines as jQuery.

Selecting DOM Elements

Summary

  • jQuery still offers the best API for extensive DOM traversal
  • jQuery might be more than you need for basic DOM access
  • In many cases, you can replace 1 line of jQuery with 1 line of plain JavaScript using the querySelector API
Skip to toolbar