10Events

WHAT YOU WILL LEARN IN THIS CHAPTER:                

  • Connecting your code to events to respond to user actions
  • Writing standards-compliant, event-driven code
  • Writing event code for older versions of Internet Explorer
  • Handling the difference between standards-compliant and old-IE event models
  • Dragging and dropping content with HTML5’s native drag-and-drop capabilities
  • Animating elements by manipulating their positioning

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com code downloads for this chapter at http://www.wiley.com/go/BeginningJavaScript5E on the Download Code tab. You can also view all of the examples and related files at http://beginningjs.com.

There’s no doubt that JavaScript is a useful tool in web programming. You’ve seen how to dynamically create, remove, and manipulate HTML in the page, and in the coming chapters, you learn how to process user input and send data to the server.

Although these capabilities are very important in today’s web programming, perhaps the most important concept you’ll learn and use is that of events. In the real world, an event is, put simply, something that happens. For example, a ringing telephone is an event. If you are expecting a friend or colleague to call, you usually want to do something: Answer the call.

In programming, events are very similar to a telephone call. Something in the page will happen, and if it’s something you are expecting, you can respond to it. For example, the user clicking the page, ...

Get Beginning JavaScript, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.