DOM Programming with JavaScript
William Turner, Steve Leonard · 2017
This chapter shows you how to add JavaScript to CSS and HTML . By the end of the chapter, you will have created a fully functioning application with interactive controls . How Does JavaScript Communicate with the DOM? The DOM (Document Object Model) contains a collection of JavaScript properties and methods that allows you to manipulate HTML elements and to write code that responds to user-invoked actions such as mouse clicks and form submissions . Typically, when writing an application, you want to ask yourself two things . The first is, what do you want or expect the user to do? The second is, what should happen in response to user actions? So for example, the following code contains a play button, and when a user clicks it the browser runs a built-in function called alert . This function displays a pop-up with the message: You clicked play .