jQuery event.dataProperty
Examples
For each <p> element, return the data passed via the on() method:
$("p").each(function(i){
$(this).on("click",{x:i},function(event){
alert("Serial number: " + $(this).index() + ". Paragraph data: " + event.data.x);
});
});
$(this).on("click",{x:i},function(event){
alert("Serial number: " + $(this).index() + ". Paragraph data: " + event.data.x);
});
});
Try it Yourself »
Definition and Usage
The event.data property contains the optional data passed to the event method when the currently executing handler was bound.
Syntax
event.data
| Parameters | Description |
|---|---|
| event | Required.eventThe parameter comes from the event binding function. |
Other Extensions
jQuery Event Methods