With jQuery code like:
$("#myid").click(myfunction);
function myfunction(arg1, arg2)
{/* something */}
How do I pass arguments to myfunction while using jQuery???
With jQuery code like:
$("#myid").click(myfunction);
function myfunction(arg1, arg2)
{/* something */}
How do I pass arguments to myfunction while using jQuery???
Do it like so
$("#myid").click(function() {
myfunction(arg1, arg2);
});
This create an anonymous function, which is called when you run the click event.
while you should certainly use Alex's answer, the prototype library's "bind" method has been standardized in Ecmascript 5, and will soon be implemented in browsers natively. It works like this:
jQuery("#myid").click(myfunction.bind(this, arg1, arg2));