<form id="form" method="post">
<input type="text" name="ceshi" value="測試"/><button type="button" id="submit">提交</button>
</form>
<script type="text/javascript">
$(function(){
$('#submit').click(function(){
$('#form').submit()
})
})
</script>
上述代碼看上去貌似沒什麼問題,但是點擊查詢按鈕的時候死活不提交表單,按鈕type改爲submit表單提交正常。
Additional Notes: Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.
其他注意事項: 表單和其子元素不宜用一個表單的屬性的屬性作爲name或id的名稱,如submit, length, or method,是、會產生衝突。名稱衝突可能會導致混亂的失敗。對於一個完整的規則列表,並檢查這些問題標記,看DOMLint。
然後我把id名字改了就執行了。