BernardoLima
BernardoLima

Reputation: 1141

Set selected select option using HTML only

What's the property to select an option from a select element form bootstrap, only using HTML?

Example:

<select ?PROPERTY_DEFAULT_OPTION?=3>
   <option value="1">Blue</option>
   <option value="2">Yellow</option>
   <option value="3">Green</option>
   <option value="4">Brown</option>
</select>

What would be the property name to set the default selected option to value 3?

Upvotes: 0

Views: 96

Answers (1)

Kamil
Kamil

Reputation: 2005

Use following code:

<select>
    <option value="1">Blue</option>
    <option value="2">Yellow</option>
    <option value="3" selected>Green</option>
    <option value="4">Brown</option>
</select>

All you need to use is a selected property.

And it's not even bootstrap, it's pure HTML.

Upvotes: 2

Related Questions