HTML 5 <select> 標(biāo)簽
定義和用法
<select> 標(biāo)簽創(chuàng)建下拉列表。
HTML 4.01 與 HTML 5 之間的差異
HTML 5 有一些新的屬性,同時不再支持一些 HTML 4.01 的屬性。
提示和注釋:
提示:請在 form 元素中使用此標(biāo)簽來接受用戶的輸入。
例子
<select>
<option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option></select>
屬性
屬性 | 值 | 描述 | 4 | 5 |
---|---|---|---|---|
autofocus |
|
在頁面加載時使這個 select 字段獲得焦點。 | 5 | |
data | url | 供自動插入數(shù)據(jù)。 | 5 | |
disabled |
|
當(dāng)該屬性為 true 時,會禁用該菜單。 | 4 | 5 |
form |
|
定義 select 字段所屬的一個或多個表單。 | 5 | |
multiple |
|
當(dāng)該屬性為 true 時,規(guī)定可一次選定多個項目。 | 4 | 5 |
name | unique_name | 定義下拉列表的唯一標(biāo)識符。 | 4 | 5 |
size | number | 定義菜單中可見項目的數(shù)目。不支持。 | 4 |
標(biāo)準(zhǔn)屬性
class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title
如需完整的描述,請訪問 HTML 5 中標(biāo)準(zhǔn)屬性。
事件屬性
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 中事件屬性。