Code Editor
Web Browser
Learn
jQuery Setup

Event Handlers

Now that we've got jQuery up and running, let's give it a little gas! The jQuery .on() method adds event handlers to jQuery objects. The method takes two parameters: a string declaring the event to listen for (the handler) and a callback function to fire when the event is detected.

$('#login').on('click', () => { $loginForm.show(); })

In the example above, we use .on() to add the click event handler to the #login element. Inside of the callback function, we use the .show() method to show the jQuery object saved in the $loginForm variable.

When a user clicks the login element, the login form appears.

Let's try it out on our site!

Report a Bug
If you see a bug or any other issue with this page, please report it here.