© Jack Franklin, Russ Ferguson 2017

Jack Franklin and Russ Ferguson, Beginning jQuery, https://doi.org/10.1007/978-1-4842-3027-5_5

5. An Introduction to Events

Jack Franklin and Russ Ferguson2

(1)Aviation House, GDS, 6th Floor Aviation House, London, UK

(2)Apt 129, Ocean, New Jersey, USA

When you write JavaScript in the browser, you’re writing event-driven code. Most of your code will be executed when something happens, such as having content slide in when a user clicks a link. Even though you might not have realized it, you’ve already written some event-based code:

$(function() {});

You’ve been writing code that runs when the document is ready, as previously explained. This is an event that you’re attaching code to. It is also known as binding. Keeping ...

Get Beginning jQuery: From the Basics of jQuery to Writing your Own Plug-ins 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.