HTMLOptionsCollection

HTMLOptionsCollection is an interface representing a collection of HTML option elements (in document order) and offers methods and properties for traversing the list as well as optionally altering its items. This type is returned solely by the "options" property of select.

MDN Reference

Properties

Link copied to clipboard
open override var length: Int

Returns the number of elements in the collection.

Link copied to clipboard

Returns the index of the first selected item, if any, or −1 if there is no selected item.

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)

Inserts element before the node given by before.

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?

Retrieves an object from various collections.

Link copied to clipboard
open inline operator fun iterator(): Iterator<HTMLOptionElement>
Link copied to clipboard

Retrieves a select object or an object from an options collection.

Link copied to clipboard
fun remove(index: Int)

Removes the item with index index from the collection.