Passing additional parameters to JQuery bind event function
- by kazim sardar mehdi
To pass the additional parameter to the event function pass an array of key value, as the second parameter to the bind event
bind('click', { message: time }, onClick);
e.g
{ message: time }
and access it in the function
using event(function parameter).data.message(key)
<div id="div1" style="border: 1px solid black; width: 100px; height: 100px">click me</div> <script type="text/javascript"> function onClick(event) { alert(event.data.message); } var time = "loaded at:" + new Date().toString(); $("div.#div1").bind('click', { message: time }, onClick); </script>