定義和用法
<option> 標簽定義下拉列表中的一個選項。
HTML 4.01 與 HTML 5 之間的差異
在 HTML 5 中,<option> 標簽也用于新元素 <datalist> 中。
提示和注釋
注釋:<option> 標簽能夠在不帶任何屬性的情況下使用,但是通常需要 value 屬性,該屬性定義了發送到服務器的數據。
注釋:請與 <select> 或 <datalist> 標簽結合使用。在其他地方,<option> 標簽是無意義的。
例子
<select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel" selected="selected">Opel</option> <option value="audi">Audi</option> </select>
屬性
屬性 | 值 | 描述 | 4 | 5 |
---|---|---|---|---|
disabled | disabled | 規定此選項應在首次加載時被禁用。 | 4 | 5 |
label | text | 定義當使用 <optgroup> 時所使用的標注。 | 4 | 5 |
selected | selected | 規定選項(在首次顯示在列表中時)表現為選中狀態。 | 4 | 5 |
value | text | 定義送往服務器的選項值。 | 4 | 5 |
標準屬性
class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title
如需完整的描述,請訪問 HTML 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 中事件屬性。