我正在使用 Safari 5.0.3 我的 html 中有一个表单:
<form name="searchForm" style="margin-top:24px;">
<h4 style="float:left;margin-top:-1px;">Search</h4>
<input type="text" name="keywords" id="keywords"></input> <a href="#" onClick="document.forms[0].submit(); return false">Go ></a>
</form>
这工作正常:
a href="#" onClick="document.forms[0].submit(); return false"
但这没有任何作用:
a href="#" onClick="document.forms['searchForm'].submit(); return false"
我需要使用后者,因为页面模板是动态的,有时页面中在这之前会有一个表单。
使用: document.getElementById('searchForm').submit() 代替。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)