Home  >  Article  >  Web Front-end  >  JS方法调用括号的问题探讨_基础知识

JS方法调用括号的问题探讨_基础知识

WBOY
WBOYOriginal
2016-05-16 17:02:451297browse

移动端的html页面,

写了一个函数.

复制代码 代码如下:

function showAlert(msg,fn){
showDialog("alert", msg,"温馨提示",260);
if(isNull(fn) == false){
$("#SD_confirm").unbind("click");
$("#SD_confirm").bind("click",fn);
}
}

function exist(){

alert("aaa");

}

fn是一个函数,调用的时候我就写了
复制代码 代码如下:

showAlert(json.msg,exist());

结果一到这行代码的时候,还没走到showDialog方法,就走exist弹出aaa了,这咋回事啊,后来才发现写错了.

应该写成
复制代码 代码如下:

showAlert(json.msg,exist);

这样就会先弹出dialog温馨提示,然后点击确定才会弹出aaa.

妹的.原来是括号出的错.汗!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn