我的页面上有这个按钮,它指向函数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
很明显函数是定义的,为什么我看到这个错误? 是因为我用流体渲染按钮吗?
我还尝试用[{1}}包装函数download()
,
但这没有改变。
$(document).ready();
答案 0 :(得分:3)
请更改功能名称。
<html>
<script>
function download1(button)
{
console.info(button);
return true;
}
</script>
<body>
<a class="myButton" onclick='download1(this);'>Download</a>
</body>
</html>