One minute
Passing arguments in an event handler Javascript
👴 Careful You’re reading an old article ! Some links might be broken and content may be outdated
I had this problem while working on Leaflet but I think it can be generalized to the issue of passing parameters to an event handler in Javascript. With the « bind » method of jQuery, you can pass parameters by using the data property of event (the object sent when an event is triggered) :
As « marker » was a L.Marker object, I had to convert it into a jQuery object before applying the bind method. Thank you Anurag on StackOverflow !!
Read other posts