With HTML one can set the default selected item like this:
<option value="blaah" selected>
But how to do it with HTML5 and DataList select?
Not per se. Just set the value
as normal.
<label for="ice-cream-choice">Choose a flavor:</label>
<input list="ice-cream-flavors" id="ice-cream-choice" name="ice-cream-choice" value="Strawberry" />
<datalist id="ice-cream-flavors">
<option value="Chocolate">
<option value="Coconut">
<option value="Mint">
<option value="Strawberry">
<option value="Vanilla">
</datalist>
Of course, clicks in the input will be filtered by the text already there, so users will have to delete it to get the list of suggestions back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With