HTMLOptionsCollection
Overview
HTMLOptionsCollection is a class in Aspose.Html FOSS for Python.
Live collection of <option> elements for a <select>.
This class provides 6 methods for working with HTMLOptionsCollection objects in Python programs.
Available methods include: __init__, add, item, namedItem, named_item, remove.
All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package.
Properties: length, selectedIndex, selected_index.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
length | int | Read | Number of <option> elements in the collection. |
selected_index | int | Read | 0-based index of first selected option, or -1. |
selectedIndex | int | Read | Alias for :attr:selected_index (Web IDL casing). |
Methods
| Signature | Description |
|---|---|
__init__(select_element: Node) | Calls init(select_element) on this HTMLOptionsCollection instance. |
item(index: int) → Node | None | Return option at index, or None if out of range. |
named_item(name: str) → Node | None | Return first option whose id or name equals name. |
namedItem(name: str) → Node | None | Alias for :meth:named_item (Web IDL casing). |
add(element: Node, before: Node | int | None) | Insert element into the select at a requested position. |
remove(index: int) | Remove option at index if present. |