<script type="text/javascript">
window.onload = function() {
document.getElementById('finalize_btn_top').onclick='bmlAuth();';
document.getElementById('finalize_btn_bottom').onclick='bmlAuth();';
}
function bmlAuth(){
//
}
</script>
我研究了谷歌搜索结果,这应该有效,但它不起作用。我将其放在页面底部只是为了确保元素已加载。
<input id="finalize_btn_bottom" type="image" name="" value="continue" onmouseover="this.src='<% =strFolder %>/images/b_submitorder_on.gif';" onmouseout="this.src='<% =strFolder %>/images/b_submitorder_off.gif'" src="<% =strFolder %>/images/b_submitorder_off.gif" alt="continue" onclick="bml_submit();">
我需要做哪些不同的事情?
非常感谢!
最佳答案
尝试传入函数引用:
var $ = document.getElementById;
$('finalize_btn_top').onclick = bmlAuth;
$('finalize_btn_bottom').onclick = bmlAuth;
关于javascript - 我可以使用 getElementById 更改其 onclick 事件值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9402953/