Reacting to User Input Events and Updating the DOM
JavaScript is used to interact with the DOM. This entails responding to DOM-generated events such as a user clicking a button. It also entails updating content and HTML elements, such as displaying a notification message.
Elements in the DOM are objects. The document
object that's provided by JavaScript contains the element objects. It also contains methods for accessing the elements and updating them.
The DOM HTML Element Object
The HTML elements are represented as objects. Since they are objects, there are methods and properties we can use for them. These properties and methods are inherited from a hierarchy of DOM objects that are provided by the web browser, starting with an object called Node
. For example, the ol
element shares methods and properties from the following hierarchy of DOM objects:
Node->Element->HTMLElement->HTMLOListElement
It is not necessary to understand all the objects involved,...