HTMLOptionsCollection

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

NameTypeAccessDescription
lengthintReadNumber of <option> elements in the collection.
selected_indexintRead0-based index of first selected option, or -1.
selectedIndexintReadAlias for :attr:selected_index (Web IDL casing).

Methods

SignatureDescription
__init__(select_element: Node)Calls init(select_element) on this HTMLOptionsCollection instance.
item(index: int)Node | NoneReturn option at index, or None if out of range.
named_item(name: str)Node | NoneReturn first option whose id or name equals name.
namedItem(name: str)Node | NoneAlias 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.

See Also