【发布时间】:2012-06-08 19:29:45
【问题描述】:
可能重复:
In JavaScript, does it make a difference if I call a function with parentheses?
这有什么区别:
$("a").on("click", anotherFunction);
还有这个:
$("a").on("click", anotherFunction());
有没有办法在没有匿名函数的情况下不让最后一个自可执行?
【问题讨论】:
-
我想你想要这个:
$('a').on('click', anotherFunction).triggerHandler('click');。所以该函数变成了点击处理程序并且也被立即调用。
标签: javascript