博主以前遇到这样的问题,是由于代码有错,改正以后就正常了。html
但今天肯定代码没错,仍然return false提交表单。jquery
总结网上各路大神的解释:git
1.onsubmit的做用是防止form只有一个input时提交表单github
2.onsubmit的做用是先提交表单的动做再执行函数,最后不管函数返回正确与否都完成提交动做浏览器
具体真相读者自行百度吧。我偏向2,但与我以前的状况相悖,也不彻底肯定。dom
作法:函数
只能麻烦一点将input submit换成input button了。fun里设置表单提交,不用多解释了吧.net
可是,<button id="submit" onclick="check();">下一题</button>不管funciton里怎么写代码仍然提交code
表单,再次查询得知button只有IE才默认是button,其余浏览器和W3C规范都默认是submitorm
因此正确作法是:<button id="submit" type="button" onclick="check();">下一题</button>
但问题再次出现,form不提交了。再次查询缘由,发现这篇博文遇到了一样的问题。原文:
点击提交按钮出现确认提示,可是确认后就没反应了
可是将button的type改成submit却又能提交
因而上jQuery API查找缘由,看到如下这段文字顿时明白了:
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, 和 method等,不然会产生冲突,名称冲突可能就会致使这种状况。
对号入座,我确实将button的id设置了submit,改后就行了