views:

25

answers:

2

I have a javascript function with arguments that I want to call in jQuery and I am stuck.

I tried this : $("a").click(highlight(arg)) but it doesnt work.

Any ideas ?

Johanna

+3  A: 

Try this:

$("a").click(function(){
    highlight(arg);
});
J-P
A: 
$('a').click(highlight);

that would be a total bypass.

otherwise: eg. if you need a specific property of event

$('a').click(function(event) {
    highlight(event.specialProp);
});

otherwise: eg. if you declared args yourself

var args = 'demoArgs';
$('a').click(function() {
    higlhight(args);
});
Andreas Niedermair