我的索引页面上有一个输入:
<input type="button" name="goReplaceAll" value="Go" id="allReplaceGo" style="cursor:hand;" />
以及来自 jquery 的 onclick 调用:
$(document).ready(function() {
$('#allReplaceGo').click(replaceAll);
});
function replaceAll(){ alert('a'); }
当我单击按钮时,什么也没有发生。当我在 HTML 中使用 onclick="replaceAll()" 时,我收到一个错误:Uncaught ReferenceError: replaceAll is not defined
我无法弄清楚这些错误之间的联系,或任何可能的原因。
该代码目前位于http://www.texturepacker.net
编辑:看起来我在 Firefox 和 Chrome 中得到了两个不同的结果,Chrome 在页面加载后 Firefox alert('a')'s 什么都不做。现在我只是很困惑?
编辑:在我的代码后面似乎有一个不相关的语法错误正在中断调用。现在在 dom 加载时调用 replaceAll(),我现在的问题是为什么没有在单击时启动 replaceAll() 而是在 dom 加载后,我是否遗漏了一些明显的东西?