Chapter 3. Events, Handlers and All that Jazz: A Little Interaction
You still haven’t reached out to touch your user. You’ve learned the basics of JavaScript but can you get interactive with your users? When pages respond to user input, they aren’t just documents anymore, they’re living, reacting applications. In this chapter you’re going to learn how to handle one form of user input (excuse the pun), and wire up an old-fashioned HTML <form> element to actual code. It might sound dangerous, but it’s also powerful. Strap yourself in, this is a fast moving to-the-point-chapter where we go from zero to interactive app in no time.
Get ready for Webville Tunes
Okay, we’ve dragged you through a lot of JavaScript fundamentals so far in this book, and while we’ve talked a good game on building web apps, we don’t have a lot to show for it, yet. So, now we’re going to get serious (no really! we mean it this time!) and build something real world.
How about a playlist manager. We’ll call it something original, like... hmm, say Webville Tunes.
Brain Power
Given what you know about this code:
window.onload = init;
Can you guess what this code might do?
button.onclick = handleButtonClick;
Getting started... ...
Get Head First HTML5 Programming 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.