Uncaught TypeError: 'download' is not a function
Uncaught TypeError: 'download' is not a function
我的页面上有这个按钮,它指向函数 download()
:
<a class="myButton" onclick='return download(this);'>Download</a>
下载():
function download(button)
{
console.info(button);
return true;
}
点击按钮后我得到:
Uncaught TypeError: download is not a function
at HTMLAnchorElement.onclick (mbnet.html:1153)
但是,如果我打开开发者控制台并执行 download
然后我得到:
function download(button)
{
console.info(button);
return true;
}
如果我执行 download()
然后我得到:
undefined
true
很明显函数已经定义了,为什么我会看到这个错误?
是因为我用流体渲染按钮吗?
我还尝试用 $(document).ready();
包装函数 download()
,
但这并没有改变什么。
$(document).ready(
function() {
function download(button)
{
console.info(button);
return true;
}
}
);
请更改函数名称。
<html>
<script>
function download1(button)
{
console.info(button);
return true;
}
</script>
<body>
<a class="myButton" onclick='download1(this);'>Download</a>
</body>
</html>
我的页面上有这个按钮,它指向函数 download()
:
<a class="myButton" onclick='return download(this);'>Download</a>
下载():
function download(button)
{
console.info(button);
return true;
}
点击按钮后我得到:
Uncaught TypeError: download is not a function at HTMLAnchorElement.onclick (mbnet.html:1153)
但是,如果我打开开发者控制台并执行 download
然后我得到:
function download(button)
{
console.info(button);
return true;
}
如果我执行 download()
然后我得到:
undefined
true
很明显函数已经定义了,为什么我会看到这个错误? 是因为我用流体渲染按钮吗?
我还尝试用 $(document).ready();
包装函数 download()
,
但这并没有改变什么。
$(document).ready(
function() {
function download(button)
{
console.info(button);
return true;
}
}
);
请更改函数名称。
<html>
<script>
function download1(button)
{
console.info(button);
return true;
}
</script>
<body>
<a class="myButton" onclick='download1(this);'>Download</a>
</body>
</html>