jQuery - Events Reference



The jQuery Events are actions that happens in the DOM (Document Object Model), which can be detected and used to trigger JavaScript functions.

jQuery simplifies event handling by providing methods to attach event handlers to elements and to trigger events. Clicking a button, hovering over an element, submitting a form, or resizing a window are common examples of events in jQuery.

jQuery Events Methods

In the following table, we have listed all the jQuery Methods used to handle events −

Sr.No. Methods & Description
1 bind()

Attach an event handler function for one or more events to the selected elements.

2 blur()

Bind a function to the blur event of each matched element.

3 change()

Bind a function to the change event of each matched element.

4 click()

Bind a function to the click event of each matched element.

5 dblclick()

Bind a function to the dblclick event of each matched element.

6 delegate()

Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.

7 error()

Bind a function to the error event of each matched element.

8 focus()

Bind a function to the focus event of each matched element.

9 focusin()

Bind a function to the focusin event of each matched element.

10 focusout()

Bind a function to the focusout event of each matched element.

11 hover()

Bind one or two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.

12 isDefaultPrevented()

Determine if the default action has been prevented by an event.

13 isImmediatePropagationStopped()

Determine if immediate propagation for an event has been stopped.

14 isPropagationStopped()

Determine if propagation for an event has been stopped.

15 keydown()

Bind a function to the keydown event of each matched element.

16 keypress()

Bind a function to the keypress event of each matched element.

17 keyup()

Bind a function to the keyup event of each matched element.

18 live()

Attach an event handler function for one or more events to the selected elements.

19 mousedown()

Bind a function to the mousedown event of each matched element.

20 mouseenter()

Bind a function to the mouseenter event of each matched element.

21 mouseleave()

Bind a function to the mouseleave event of each matched element.

22 mousemove()

Bind a function to the mousemove event of each matched element.

23 mouseout()

Bind a function to the mouseout event of each matched element.

24 mouseover()

Bind a function to the mouseover event of each matched element.

25 mouseup()

Bind a function to the mouseup event of each matched element.

26 off()

Remove an event handler.

27 on()

Attach an event handler function for one or more events to the selected elements.

28 one()

Attach a handler to an event for the elements. The handler is executed at most once per element.

29 preventDefault()

Prevent the default action of the event from being triggered.

30 $.proxy()

Take an existing function and return a new one with a particular context.

31 ready()

Specify a function to execute when the DOM is fully loaded.

32 resize()

Bind a function to the resize event of each matched element.

33 scroll()

Bind a function to the scroll event of each matched element.

34 select()

Bind a function to the select event of each matched element.

35 stopImmediatePropagation()

Stop other handlers from being executed immediately.

36 stopPropagation()

Stop the event from bubbling up the DOM tree, preventing parent elements from being notified of the event.

37 submit()

Bind a function to the submit event of each matched element.

38 toggle()

Display or hide the matched elements based on their visibility.

39 trigger()

Execute all handlers and behaviors attached to the matched elements for the given event type.

40 triggerHandler()

Execute all handlers attached to an element for an event.

41 undelegate()

Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements.

42 unbind()

Remove a previously-attached event handler from the elements.

Event Attributes

The following event properties/attributes are available and safe to access in a platform independent manner −

Sr.No. Methods & Description
1 currentTarget

Identifies the current element within the event bubbling phase.

2 data

The value, if any, passed as the second parameter to the bind() command when the handler was established.

3 delegateTarget

Identifies the element on which the event handler was attached originally.

4 namespace

Specifies the namespace specified when the event was triggered.

5 pageX

For mouse events, specifies the horizontal coordinate of the event relative to the document.

6 pageY

For mouse events, specifies the vertical coordinate of the event relative to the document.

7 relatedTarget

For mouse events, identifies the other element involved in the event (e.g., when mouse enters or leaves an element).

8 result

For specific events, holds the result of the action (e.g., for drag events).

9 target

Identifies the element that triggered the event.

10 timeStamp

The time (in milliseconds) when the event was triggered.

11 type

Specifies the type of event that was triggered (e.g., click, hover).

12 which

For keyboard events, specifies the key code of the key that triggered the event. For mouse events, specifies the button that was pressed (1 for left, 2 for middle, 3 for right).

Advertisements