我面临一个问题 我试图在另一个 JavaScript 函数中调用 document.ready() 函数,但是当我调用它时,它显示“函数未定义”
这是我的代码: 这是第一个函数,即 document.ready() 函数
$(document).ready(function ExpandMessageBox() {// this is my document.ready function. I have given the name of it as "ExpandMessageBox"}
这是另一个常规 JavaScript 函数,我试图在其中调用上面的函数
function ShowMessageBox() {
ExpandMessageBox();}
但这给了我一个错误: “ Uncaught ReferenceError :未定义 ExpandMessageBox”
我哪里做错了... 请帮忙
提前致谢
最佳答案
您需要在公共(public)范围内定义ExpandMessageBox
函数。像这样的事情:
function ExpandMessageBox() {
//your staff
}
function ShowMessageBox() {
ExpandMessageBox();
}
$(document).ready(ExpandMessageBox);
关于javascript - 在另一个 jquery 或 javascript 函数中调用 jquery document.ready 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45372313/