wandejun1012 发表于 2013-2-7 15:15:36

html input中 button和submit的区别

type=button      就单纯是按钮功能   
type=submit      是发送表单

但是对于从事WEB UI的人应该要注意到,使用submit来提高页面易用性:
使用submit后,页面支持键盘enter键操作,而很多WEB软件设计师,可能没有注意到submit统一.

用button后往往页面不支持enter键了。所以需要支持enter键,必须要设置个submit,默认enter键对页面第一个submit进行操作。





<input type="submit" name="b1" value="提交"   >
执行完onClick,转到action。可以自动提交不需要onClick。所以说onclick这里可以不要。

<input type="button" name="b1" value="提交"   >
执行完onClick,跳转文件在 js文件里控制。提交需要onClick。





比如:

1,   这样就实现了submit的功能了。

2,<form    name="form1"    method="post"    action="http://www.sina.com.cn">   
       <input    type="button"    name="Button"    value="Button"    >   
   </form>

3,<input    type="button"    name="Button"    value="Button"    你的url"">
页: [1]
查看完整版本: html input中 button和submit的区别