w3pop.com :: ÍøÂçѧԺ :: HTML DOM :: DOM Select ¶ÔÏó
The Select object represents a drop-down list in an HTML form. For each instance of an HTML <select> tag in a form, a Select object is created.
Select¶ÔÏó´ú±íHTML±íµ¥ÖеÄÏÂÀÁÐ±í¡£Ã¿µ±±íµ¥ÖгöÏÖ<select>±êÇ©¾ÍÓÐSelect¶ÔÏó±»½¨Á¢ÆðÀ´
You can access a Select object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().
Äã¿ÉÒÔ´Ó±íµ¥Êý×éµÄÊý×Ö»òÊÇÃû³ÆÀ´·ÃÎÊSelect¶ÔÏ󣬻òÊÇʹÓÃgetELmentById()À´·ÃÎÊËü
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
| Collection ¼¯ºÏ |
Description ÃèÊö |
IE | F | N | W3C |
|---|---|---|---|---|---|
| options[] | Returns an array of all the options in a dropdown list ·µ»ØÔÚÏÂÀÁбíÖÐËùÓпÉÑ¡ÏîµÄÊý×é |
3 | 1 | 2 | Yes |
| Property ÊôÐÔ |
Description ÃèÊö |
IE | F | N | W3C |
|---|---|---|---|---|---|
| accessKey | Sets or returns the keyboard key to access the dropdown list ÉèÖûò»ñÈ¡ÏÂÀÁбí(select)¶ÔÏóµÄ¿ì½Ý¼ü¡£ |
4 | No | ||
| align | Sets or returns the alignment of the dropdown list according to the surrounding text ÉèÖûò·µ»ØÏà¶ÔÖÜΧÎÄ×ÖÏÂÀÁбíµÄ¶ÔÆë·½Ê½ |
4 | No | ||
| disabled | Sets or returns whether or not the dropdown list should be disabled ÉèÖûò·µ»ØÏÂÀÁбíÊÇ·ñΪ½ûÓà |
5 | 1 | 6 | Yes |
| form | Returns a reference to the dropdown list's parent form ÉèÖûò·µ»ØÏÂÀÁбíµÄ¸¸±í |
3 | 1 | 2 | Yes |
| id | Sets or returns the id of the dropdown list (In IE 4 this property is read-only) ÉèÖûò·µ»ØÏÂÀÁбíµÄidÖµ(ÔÚIE4Ö»Õâ¸öÊôÐÔΪֻ¶ÁÊôÐÔ) |
4 | 1 | No | |
| length | Sets or returns the number of options in the dropdown list ÉèÖûò·µ»ØÔÚÏÂÀÁбíÖпÉÑ¡ÏîÄ¿µÄÊýÁ¿ |
3 | 1 | 2 | Yes |
| multiple | Sets or returns a Boolean value that indicates whether or not multiple items can be selected ÉèÖûò»ñÈ¡±íÃ÷ÁбíÖÐÊÇ·ñ¿ÉÑ¡Öжà¸öÏîÄ¿µÄ Boolean Öµ¡£ |
3 | 1 | 6 | Yes |
| name | Sets or returns the name of the dropdown list ÉèÖûò»ñÈ¡¶ÔÏóµÄÃû³Æ¡£ |
3 | 1 | 2 | Yes |
| selectedIndex | Sets or returns the index of the selected option in the dropdown list ÉèÖûò»ñȡѡÖÐÑ¡ÏîλÓÚ select ¶ÔÏóÖеÄλÖᣠ|
3 | 1 | 2 | Yes |
| size | Sets or returns the number of rows in the dropdown list ÉèÖûò»ñÈ¡ÁбíÖеÄÐÐÊý¡£ |
3 | 1 | 6 | Yes |
| tabIndex | Sets or returns the tab order for the dropdown list ÉèÖûò»ñÈ¡¶¨Òå¶ÔÏóµÄ Tab ˳ÐòµÄË÷Òý¡£ |
5 | Yes | ||
| type | Returns the type of the form element. For a dropdown list it will be "select-one" or "select-multiple" ¸ù¾Ý MULTIPLE ÊôÐÔµÄÖµ»ñÈ¡ select ¿Ø¼þµÄÀàÐÍ¡£ |
4 | 1 | 3 | Yes |
| value | Sets or returns the value to be returned to the server when the form is submitted ÉèÖûò»ñÈ¡µ±±íµ¥¿Ø¼þÌύʱ·µ»Ø¸ø·þÎñÆ÷µÄÖµ¡£ |
3 | 1 | 6 | Yes |
| Method ·½·¨ |
Description ÃèÊö |
IE | F | N | W3C |
|---|---|---|---|---|---|
| add() | Adds an option to the dropdown list Ïò ÏÂÀÁбíÖÐÌí¼ÓÒ»¸öÑ¡Ïî¡£ |
4 | Yes | ||
| blur() | Removes focus from the dropdown list ´ÓÏÂÀÁбíÖÐÒÆ³ý½¹µã |
4 | 1 | 3 | Yes |
| focus() | Sets focus on the dropdown list ΪÏÂÀÁбíÉèÖý¹µã |
4 | 1 | 3 | Yes |
| remove() | Removes an option from the dropdown list ´ÓÏÂÀÁбíÖÐɾ³ý¿ÉÑ¡Ïî |
4 | 1 | 6 | Yes |
Syntax: object.event_name="someJavaScriptCode"
Óï·¨£º¶ÔÏó.ʼþÃû³Æ="һЩJS´úÂë"
| Event ʼþ |
Description ÃèÊö |
IE | F | N | W3C |
|---|---|---|---|---|---|
| onBlur | Executes some code when the dropdown list loses focus µ±ÏÂÀÁбíʧȥ½¹µãµÄʱºòÖ´ÐÐһЩ´úÂë |
3 | 1 | 2 | |
| onChange | Executes some code when the dropdown list loses focus and its value has altered µ±ÏÂÀÁбíʧȥ½¹µã²¢ÇÒËüµÄÖµ·¢Éú±ä»¯µÄʱºòÖ´ÐÐһЩ´úÂë |
3 | 1 | 2 | |
| onClick | Executes some code when the user clicks the left mouse button in the dropdown list µ±Óû§µã»÷ÁËÏÂÀÁбíÖ´ÐÐһЩ´úÂë |
4 | |||
| onFocus | Executes some code when the dropdown list gets focus µ±ÏÂÀÁбíµÃµ½½¹µãÖ´ÐÐһЩ´úÂë |
4 | 1 | 2 |
ÆÀÂÛ (0)
All