jQuery event.dataProperty

jQuery 事件方法jQuery Event Methods

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);
    });
});

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.


jQuery 事件方法jQuery Event Methods

Other Extensions