Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The HTMLSelectElement.add() method adds an element to the collection of option elements for this select element.
An HTMLOptionElement or HTMLOptGroupElement
before OptionalAn element of the collection, or an index of type long, representing the item should be inserted before. If this parameter is null (or the index does not exist), the new element is appended to the end of the collection.
None (undefined).
Thrown if the item passed to the method is an ancestor of the HTMLSelectElement.
The before parameter is optional. So the following is accepted.
The before parameter is optional. So the following is accepted.
| HTML # dom-select-add-dev |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 7, 2023 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.