I would like to bind to the element function, which take several arguments. How to do it right?
For example, I have function:
function test(arg1, arg2, arg3) {
console.log("arg1:", arg1);
console.log("arg2:", arg2);
console.log("arg3:", arg3);
}
and I would like to bind this to element with ID #btn, but all arguments are in array:
var array = ['Hello', ' my', ' world!'];
How can I do this? I will try something like this:
$("#btn").bind("click", array, test);
Any suggestions?
testfunction prototype.test()eventually be used to directly handle the click event?function(e){}and then access thee.datato get the arguments for thetestfunction called inside.bindfrom#btn?unbind()? Though,on()andoff()are preferable (according to docs).