$('#id').click({param: param}, function_to_run );
to bind it. Here, id is the id of the div or whatnot, param (the second one, the first one could be anything) is the variable you want to send, and the function_to_run is already written. No parens after the name, you're sending it as an object.
The tricky part is in the function itself:
function function_to_run(event) {
param = event.data.param;
get it? The click event sends the event itself as the one argument to function_to_run, and the parameters you give it are stored in data. just so you know.
around a 6 on the facepalm scale.
No comments:
Post a Comment