Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "e" mean in this function definition?

Can I pass an additional parameter to this function?

$("#foold").click( function(e) {
  // CODE
};

For example, I need to pass some X value to this function. Can I write something like this:

<a href="javascript:void(X)" id="fooId">Foo</a>

to pass value in this function through e or some other way?

like image 653
xander27 Avatar asked Feb 03 '23 07:02

xander27


1 Answers

Here, e is an event object, as defined here: http://api.jquery.com/category/events/event-object/

Yes you can pass data to the handler, using this form for the click function:

.click( [eventData], handler(eventObject) )

eventData             A map of data that will be passed to the event handler.
handler(eventObject)  A function to execute each time the event is triggered.

It will be accessible as e.data in the handler.

like image 57
SirDarius Avatar answered Feb 04 '23 21:02

SirDarius