开发者

Call a javaScript function with arguments in jQuery

I have a javascript function with arguments that 开发者_JS百科I want to call in jQuery and I am stuck.

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

Any ideas ?

Johanna


Try this:

$("a").click(function(){
    highlight(arg);
});


$('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);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜