Fam Wencong, Kenneth

My Diary

What is the DOM?

Published: Tuesday, May 12, 2020

The Document Object Model (DOM) is a programming interface for HTML documents. It represents the page so that programs can change the document structure, style, and content. It is an object-oriented representation of the web page, which can be modified with a scripting language such as JavaScript.

Although this is an important concept, you don’t have to do anything special to begin using the DOM. When you create a script – whether it’s inline in a <script> element or included in the web page by means of a script loading instruction – you can immediately begin using the API for the document or window elements to manipulate the document itself or to get at the children of that document, which are the various elements in the web page. Your DOM programming may be something as simple as an alert message by using the alert() function from the window object, or it may use more sophisticated DOM methods to actually create new content.