当前<button>标签在所有的浏览器中都是兼容的,值得注意的是再HTML表单中使用button这个元素,针对不同的浏览器会提交不同的值,例如在IE中将提交的是<button>之间的文本,而其它的浏览器提交的是VALUE属性内容,与<input>标签相比,<button>标签更具有优势,功能更加强大。那么我们来看<button>的属性有哪些。
<button>属性有:
autofocus autofocus 规定当页面加载时按钮应当自动地获得焦点。
disabled disabled 规定应该禁用该按钮。
form form_name 规定按钮属于一个或多个表单。
formaction url 覆盖 form 元素的 action 属性。
注释:该属性与 type="submit" 配合使用。
formenctype 见注释 覆盖 form 元素的 enctype 属性。
注释:该属性与 type="submit" 配合使用。
formmethod
get
post
覆盖 form 元素的 method 属性。
注释:该属性与 type="submit" 配合使用。
formnovalidate formnovalidate 覆盖 form 元素的 novalidate 属性。
注释:该属性与 type="submit" 配合使用。
formtarget
_blank
_self
_parent
_top
framename
覆盖 form 元素的 target 属性。
注释:该属性与 type="submit" 配合使用。
name
button_name 规定按钮的名称。
button_name 规定按钮的名称。
type
button
reset
submit
规定按钮的类型。
value
text 规定按钮的初始值。可由脚本进行修改。
text 规定按钮的初始值。可由脚本进行修改。
代码示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Throw-Try-Catch</title>
</head>
<body >
<button type="button">这是按钮</button>
<hr>
autofocus:<button type="button" autofocus="autofocus">这是按钮</button>
<hr>
disabled:<button type="button" disabled="disable">这是按钮</button>
<hr>
</body>
</html>
|
注意:这是部分属性,还有其他没有测试,后期补上。
运行结果:

顶一下
(0)
踩一下
(0)