I'm new to HTML5 datalists. I have setup an <input type="text">
tied to a <datalist>
following:
For instance:
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
Chrome / Chromium shows the input as a combobox, allowing one to list all the possible values:
Firefox displays the input as any other text field, but I realized one can display all the options double clicking the field, or clicking the field and pressing the down arrow key:
I need to implement a browser-agnostic button that shows that list of options when it is clicked. Like:
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<button type="button">Show options</button>
How can I implement such a button?
来源:https://stackoverflow.com/questions/57696562/html5-datalists-displaying-list-of-options-programmatically