HTMLOptionsCollection

The HTMLOptionsCollection interface represents a collection of <option> HTML elements (in document order) and offers methods and properties for selecting from the list as well as optionally altering its items.

MDN Reference

Properties

Link copied to clipboard
open override var length: Int

The length property of the HTMLOptionsCollection interface returns the number of option elements in the collection.

Link copied to clipboard

The selectedIndex property of the HTMLOptionsCollection interface is the numeric index of the first selected option element, if any, or 1 if no <option> is selected.

Functions

Link copied to clipboard
fun add(element: HTMLOptGroupElement, before: Int?)
fun add(element: HTMLOptGroupElement, before: HTMLElement? = definedExternally)
fun add(element: HTMLOptionElement, before: Int?)

fun add(element: HTMLOptionElement, before: HTMLElement? = definedExternally)

The add() method of the HTMLOptionsCollection interface adds an HTMLOptionElement or HTMLOptGroupElement to this HTMLOptionsCollection.

Link copied to clipboard
open operator fun get(index: Int): HTMLOptionElement
open operator fun get(key: Symbol.iterator): () -> JsIterator<HTMLOptionElement>
Link copied to clipboard
open override fun item(index: Int): HTMLOptionElement?

The HTMLCollection method item() returns the element located at the specified offset into the collection.

Link copied to clipboard

The namedItem() method of the HTMLCollection interface returns the first Element in the collection whose id or name attribute match the specified name, or null if no element matches.

Link copied to clipboard
fun remove(index: Int)

The remove() method of the HTMLOptionsCollection interface removes the option element specified by the index from this collection.