Reputation: 236
I have a function that looks like this:
function preview(obj){
...
}
and here is how I call the function,
$('.parent').on('click','.child',preview);
The problem is how to I define the "obj", I tried the following code, but no luck.
$('.parent').on('click','.child',{obj:event.target},preview);
Or the only way I can use is like this, which I tried and work as expected.
$('.parent').on('click','.child',function(){
preview($(this));
});
Upvotes: 0
Views: 38
Reputation: 25352
Try like this
$('.parent').on('click','.child',function(event){
preview(event.target);
});
Upvotes: 1