I am a attempting to run the below jQuery .on() method with the parameter value of 10 however whenever I do I get an
Uncaught TypeError
$(document).on("click", '.topic-btn', displayGIF(10));
It's my understanding that how it is written runs the function without a click event causing the error.
Is there a way around this? Ultimately, I want the .on("click"...
for a parameter value of 10 and a .on("dblcick"...
for a parameter value of 20.
You can change the code to this:
$(document).on("click", '.topic-btn', {'param': 10}, function(event){
displayGIF(event.data.param);
});
The data to on can be passed using the above method. Refer docs: http://api.jquery.com/on/
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