Binding and Unbinding Events

Functions for registering behaviors that take effect when the user interacts with the browser.

Preventing the default action or bubbling of events

How to cancel an event or preventing it from bubbling up the DOM tree.

jQuery: e.preventDefault(), e.stopPropagation()

Getting the keycode from keyboard events

Binding an event handler to keyboard actions and retrieving the keycode that triggered the event.

jQuery: $.keypress(), $.keyup(), $.keydown()

Getting the current mouse position

How to get the current mouse position on mouse move or click.

jQuery: $.mousedown(), $.click(), $.mouse...

Running code when the document is ready

A page can't be manipulated safely until the document is "ready." Here's how to make sure code isn't run prematurely.

jQuery: $(document).ready()

Live binding event handlers

Attach an event handler for all elements which match a given selector, now and in the future.

jQuery: $.live(), $.on(), $.bind()

Binding and unbinding of event handlers

How to attach or detach a handler function to an event, such as click, focus, or submit.

jQuery: $.on(), $.bind(), $.live(), $.click(), $.focus(), $.submit(), etc.

Trigger an event

How to create and dispatch events. Corresponding functions to jQuery's $.trigger(), $.click(), $.blur(), $.keyup(), $.mousedown(), etc.

jQuery: $.trigger(), $.click(), $.focus(), $.submit(), etc.