event.data Property - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:event.data

jQuery event.data Property


The event.data property contains the optional data passed to an event method.


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

The following code shows how to Return the data passed with the on() method for each <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        $(this).on("click", {x:i}, function(event){
            console.log("The " + $(this).index() + ". paragraph has data: " + event.data.x);
        });/*  w w  w  . j  a  va 2s.c  o m*/

<p>Click on each p element to return the data passed with the on() method.</p>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<p>This is another paragraph.</p>


Related Tutorials