Easy Tutorial
❮ Misc Contains Traversing Nextuntil ❯

jQuery event.data Property

jQuery Event Methods

Example

Return the data passed through the on() method for each <p> element:

$("p").each(function(i){
    $(this).on("click", {x: i}, function(event){
        alert("Index: " + $(this).index() + ". Data of the paragraph: " + event.data.x);
    });
});

Definition and Usage

The event.data property contains optional data passed to an event method when the handler is bound.


Syntax

Parameter Description
event Required. The event parameter comes from the event binding function.

jQuery Event Methods

❮ Misc Contains Traversing Nextuntil ❯