in your exemple, you can simply remove the parameter since the
function is declared as a closure that capture your var $id.
In most cases, callback function doesn't have any parameter, unless
explicitely specified in the documentation.
If you need to pre-bind parameters to your callback function
There's no need to pass it. Since var $id and your callback are in the same
function-scope, a closure provides access. Here's a simpler example to
illustrate:
$(document).ready(function() {
var i = 3;
$("div").click(function() {
alert(i); // i and div.click fn are in the same function scop
Please ignore the fact that the single quotes are being escaped.
Thanks
Donald wrote:
> Is i possible to pass arguments to callback functions right now I
> have:
>
> $(".imagethumb").each(function() {
> $(this).bind( \'click\', function() {
> var $id = $(this)[0].id;
> $("#pr
3 matches
Mail list logo