如何将函数放入函数中?如何从函数内部调用函数?
do_something(){
alert('do something');
}
also_do_something = function(){
alert('also do something');
};
inp.onclick = function(){
do_something();
// this don't work
also_do_something;
};
如何将函数放入函数中?如何从函数内部调用函数?
do_something(){
alert('do something');
}
also_do_something = function(){
alert('also do something');
};
inp.onclick = function(){
do_something();
// this don't work
also_do_something;
};
要调用的函数,你必须增加括号:
inp.onclick = function(){
do_something();
also_do_something();
};
面团..我甚至没有想到.. hehe – clarkk 2011-04-25 16:54:20
also_do_something
是一个函数引用,你不叫,你只是得到它。如果你想打电话,使用also_do_something()
调用一个函数,你需要添加括号:
inp.onclick = function(){
do_something();
// this don't work
also_do_something();
};
很想听到什么让你把括号中do_something()
,而不是在also_do_something
?
@nEEbz ...它可能与声明'also_do_something = function()'有关,也许你需要做的就是调用'also_do_something'?尽管@克拉克的头虽然......我不知道发生了什么......只是一个猜测 – Hristo 2011-04-25 16:35:23
哟dawg我们听到你喜欢的功能.... – 2011-04-25 16:27:39
@ josh.trow你让我的一天 – 2011-04-25 16:30:24
我lawl'd。那太棒了。 – Eli 2011-04-25 16:36:16