CHAPTER 6

image

More Events

At the end of the last chapter, you ended up with a respectable accordion, which was the first major bit of jQuery you’d embarked on. You might not have realized it, but the code you wrote could be tidied up. In this chapter, we’ll finish events by looking at the more advanced features, including:

  • Event delegation
  • Event propagation
  • Preventing default behavior
  • Creating your own events

Once we’ve covered these features, you’ll take another look at your accordion and do some refactoring to improve the code and make it more efficient. Chapter 7 will look at animation in depth, and you’ll again use the accordion example to ...

Get Beginning jQuery 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.