Tag Archive for 'button'

HTML button 标签的默认 Type 属性

Posted on 2008-02-21 in Web DevelopmentComments

在装上 K2 RC4 主题后,发现如果用 IE 访问 WP 后台无法保存 K2 的设置选项,点击 Save 按钮后毫无反应,Firefox、Opera、Safari则正常。看了看源代码,K2 是这样定义这个按钮的:


之前很少使用过 <button> 标签,所以开始还以为 K2 绑定了按钮事件不支持 IE,不过浏览了一通代码也没找到,才意识到问题可能出在标签的未指定 type 属性上了,于是加上 type=”submit”,问题解决。

又特意找了找相关资料,W3C 对 button 标签的 type 属性定义是:

submit: Creates a submit button. This is the default value.
 reset: Creates a reset button.
button: Creates a push button.

MSDN 中则如此解释:

button: Default. Creates a Command button.
 reset: Creates a Reset button. If the button is in a form,
        it resets the fields in the form to their initial values.
submit: Creates a Submit button. If the button is in a form,
        it submits the form.

原来如此。fuck IE!