Chapter 9
Events and DOM Manipulation
In this chapter, we return to JavaScript’s native environment and put our newly created Node module to work in the browser. Specifically, we’ll be making a simple single-page JavaScript application that takes in a string from the user and indicates whether or not that string is a palindrome.
Our approach involves gradually increasing levels of sophistication, starting with a simple “hello, world”–style proof-of-concept (Section 9.1). We’ll then add a prompt/-alert design that will motivate the introduction of event listeners (Section 9.2). In Section 9.3, we’ll replace the alert with dynamic HTML inserted on the page itself—our first example of manipulating the Document Object Model tree. Finally, in Section ...
Get Learn Enough JavaScript to Be Dangerous: Write Programs, Publish Packages, and Develop Interactive Websites with JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.