目录搜索
文字
分享

HTML 5 <button> 标签

定义和用法

<button> 标签定义按钮。您可以在 button 元素中放置内容,比如文档或图像。这是该元素与由 input 元素创建的按钮的不同之处。

HTML 4.01 与 HTML 5 之间的差异

在 HTML 5 中有一个新属性:autofocus。

例子:

1

<button>Click Me!</button>

属性

属性 描述 4 5
autofocus true | false 在页面加载时,是否让按钮获得焦点。   5
disabled disabled 禁用按钮 4 5
name button_name 为按钮规定为一的名称。 4 5
type
  • button
  • reset
  • submit
定义按钮的类型。 4 5
value some_value 为按钮规定初始值。该值可通过脚本改变。 4 5

标准属性

1

2

class, contenteditable, contextmenu, dir, draggable, id, irrelevant,

lang, ref, registrationmark, tabindex, template, title

如需完整的描述,请访 HTML 5 中标准属性。

事件属性

1

2

3

4

5

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu,

ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover,

ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup,

onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout,

onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

如需完整的描述,请访 HTML 5 中事件属性。