Class Option


@Bean(typeName="option") public class Option extends HtmlElementText
DTO for an HTML <option> element.

The option element represents an option in a select element or a suggestion in a datalist element. It defines a choice that users can select from a dropdown menu or autocomplete list. The value attribute specifies the value to be submitted, while the text content provides the display text.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple option Option option1 = option("red", "Red"); // Selected option Option option2 = option("blue", "Blue") .selected(true); // Disabled option Option option3 = option("gray", "Gray") .disabled(true); // Option with label Option option4 = option("green", "Green") .label("Green Color"); // Options in a select Select select1 = select("color", option("red", "Red"), option("green", "Green"), option("blue", "Blue") );

The following convenience methods are provided for constructing instances of this bean:

See Also: