예배 규칙서 찾다
Attributes accesskey (attribute) class (attribute) contenteditable (attribute) contextmenu (attribute) data-* (attribute) dir (attribute) draggable (attribute) dropzone (attribute) Global attributes hidden (attribute) id (attribute) itemid (attribute) itemprop (attribute) itemref (attribute) itemscope (attribute) itemtype (attribute) lang (attribute) slot (attribute) spellcheck (attribute) style (attribute) tabindex (attribute) title (attribute) translate (attribute) Elements a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 head header hr html i iframe img input input type="button" input type="checkbox" input type="color" input type="date" input type="datetime"-local input type="email" input type="file" input type="hidden" input type="image" input type="month" input type="number" input type="password" input type="radio" input type="range" input type="reset" input type="search" input type="submit" input type="tel" input type="text" input type="time" input type="url" input type="week" ins kbd label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt rtc ruby s samp script section select slot small source span strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track u ul var video wbr Miscellaneous Attributes Block-level elements CORS enabled image CORS settings attributes Element Inline elements Kinds of HTML content Link types Microdata Optimizing your pages for speculative parsing Preloading content Reference Supported media formats Using the application cache Obsolete acronym applet basefont big blink center command content dir element font frame frameset hgroup image input type="datetime" isindex keygen listing marquee nextid noframes plaintext strike tt xmp
문자

HTML<select> 元素是一种表单控件,可创建选项菜单。菜单内的选项为<option> , 可以由 <optgroup> 元素分组。选项可以被用户预先选择。

内容类别


flow content, phrasing content, interactive content, listed, labelable, resettable, and submittable form-associated element

允许的内容

零个或多个<option>或<optgroup>元素。

标记遗漏

没有,起始和结束标签都是强制性的。

允许父母

任何接受 phrasing content 的元素

允许ARIA角色

menu

DOM界面

HTMLSelectElement

属性

这个元素包含全局属性。

autofocusHTML5这个属性能够让一个对象在页面加载的时候获得焦点. 在一个页面上下文中, 只有一个对象可以有这个属性,并且是布尔值(true 或者 false).

disabled这个布尔值的属性表明一个用户是否可以操控该表单对象. 如果这个属性没有被明确定义, 则从它的父元素继承, 例如 fieldset; 如果没有父元素设置 disabled属性, 那么默认该表单对象 enabled.

formHTML5select所关联的form表单 (它的"表单拥有者"). 如果这个属性被明确定义, 那么它的值一定是在同一个document中表单ID. 这样能够让你把select标签放在任何的位置, 不仅限于作为form表单的后代元素.

multiple这个布尔值的属性标记select是否可以多选. 默认是单选.

name控件名称

requiredHTML5规定select的值不能为空(布尔值).

size如果控件显示为滚动列表框,则此属性表示为控件中同时可见的行数。浏览器不需要将选择元素呈现为滚动列表框。默认值为0

Firefox注意:根据HTML5规范,大小的默认值应该是1; 然而,在实践中,这被发现打破了一些网站,目前没有其他的浏览器这样做,所以Mozilla选择继续返回0暂时与Firefox。

例子

<!-- The second value will be selected initially -->
<select name="select"> <!--Supplement an id here instead of using 'name'-->  
    <option value="value1">Value 1</option> 
    <option value="value2" selected>Value 2</option>  
    <option value="value3">Value 3</option>
</select>

结果

Value 1 Value 2 Value 3

注意

这个元素的内容是静态的,不可编辑。

规范

Specification

Status

Comments

HTML Living StandardThe definition of '<select>' in that specification.

Living Standard


HTML5The definition of '<select>' in that specification.

Recommendation


HTML 4.01 SpecificationThe definition of '<select>' in that specification.

Recommendation


浏览器兼容性

Feature

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Basic Support

(Yes)2

(Yes)

13

(Yes)

(Yes)

(Yes)2

autofocus

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

disabled

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

form

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

multiple

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

name

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

required

(Yes)

(Yes)

4

10

(Yes)

(Yes)

size

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(Yes)1 2

(Yes)2

(Yes)

14

(Yes)

(Yes)

(Yes)2

autofocus

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

disabled

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

form

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

multiple

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

name

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

required

(Yes)

(Yes)

(Yes)

4

No

(Yes)

(Yes)

size

(Yes)

(Yes)

(Yes)

1

(Yes)

(Yes)

(Yes)

이전 기사: 다음 기사: