O'Reilly logo

Head First HTML5 Programming by Eric Freeman, Elisabeth Robson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Events, Handlers and All that Jazz: A Little Interaction

image with no caption

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.

image with no caption

How about a playlist manager. We’ll call it something original, like... hmm, say Webville Tunes.

image with no caption

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... ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required