Select Object
The add() method is used to add an option to a dropdown list.
| Parameter | Description |
|---|---|
| option | Required. Specifies the option to add. Must be an option or optgroup element |
| before | Required. Where to insert the new option (null indicates that the new option will be inserted at the end of the list) |
![]()
The add() method is supported in all major browsers.
Tip: For this method to work in IE8 and higher, add a !DOCTYPE
declaration to the page. Also notice the extra code for IE prior version 8.
Insert a "Kiwi" option at the end of the dropdown list:
Add an option before a selected option in a dropdown list
Select Object
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $7.95/mo SEO Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| XML Editor - Free Trial! |
| FREE Website BUILDER |
| Free Website Templates Free CSS Templates |
| Make Your Own Website |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|