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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With