我有一个名为tryMe的函数,我在没有括号的情况下调用它并不是这样,但这个想法就像你在这里做的那样:
I have a function called "tryMe" and I'm calling it without the parenthesis not precisely this but the idea is like what you would do here:
setTimeout(tryMe,200);如何传递我需要的参数?
how can I pass parameters that I need?
我正在使用一个jquery插件,它允许我调用一个函数,但我必须用括号调用它,或者它在加载时自行执行。
I am using a jquery plugin that enables me to call a function but I have to call it withou the parenthesis or it executes itself upon loading.
推荐答案setTimeout(function() { tryMe(parm1, parm2); }, 200);
更强大的产品,确保 parm1的值, parm2 在超时发生之前不要更改(@ lincolnk的评论):
A more robust offering, to ensure that the values of parm1, parm2 don't change before the timeout fires (per @lincolnk's comment):
setTimeout(function() { var p1 = parm1; var p2 = parm2; tryMe(p1, p2); }, 200);
@patrick dw,你是对的,必须先评价。
@patrick dw, you're right, has to be evaluated before.
更多推荐
如何在没有括号的情况下调用函数时传递参数[Javascript]
发布评论