Is there any way by which I can make an input type=text element look like a dropdown? Currently I have a text box which when clicked I am displaying options using jquery and div. I want the text box to have a drop down icon to make it exactly look like a regular dropdown.
Also since different browsers have different dropdown icon is there a way to use the same dropdown icon that the browser provides?
Note: I have to apply some css to the option values before displaying it which I cant do using regular dropdown. That is why I have used div and jquery to display the option values.
The <datalist> Element Users will see a drop-down list of the pre-defined options as they input data. The list attribute of the <input> element, must refer to the id attribute of the <datalist> element.
When an item (option) is selected in DropDownList (HTML SELECT), the EnableDisableTextBox JavaScript function is executed. Inside this function, based on whether the Other option (item) is selected, the TextBox will be enabled else disabled. The HTML Markup consists of a DropDownList (HTML SELECT) and a TextBox.
Try this example!
<div>Choose a browser from this list:</div>
<input list="browsers" />
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
</datalist>
<div>Choose a browser from this list:</div>
<input list="browsers" />
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
</datalist>
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