开发者

Is there a Jquery plugin to replace the select tag which lets users type in their own option?

开发者 https://www.devze.com 2023-02-19 05:56 出处:网络
I\'m looking for a jquery plugin to replace the html select input. It should behave in the same way开发者_如何学编程 as the regular select, but also contain a textbox allowing the user to enter in the

I'm looking for a jquery plugin to replace the html select input. It should behave in the same way开发者_如何学编程 as the regular select, but also contain a textbox allowing the user to enter in their own option.

For example, imagine this were valid markup:

Favorite fruit:
<select>
  <option value="op1"> Apples </option>
  <option value="op2"> Bananas </option>
  <option value="new"> other: <input/> </option>
</select>


You could probably use jQueryUI's autocomplete to hack something up which behaves similarly, for example:

var fruits = ["apples", "oranges"];
$("input").autocomplete({
    source: fruits,
    minLength: 0
}).autocomplete("search", "");


Select preset from list or type something: <input type="text"/>

Play with it here.


There is the editable combobox plugin.

Or do you mean something like this question whose answer points to this demo? It come close, at least, to what you are talking about.


I've used flexbox before, and it works pretty well for me. It allows typing of answers, like the jQuery UI autocomplete does, but also allows the standard dropdown box selection methods. The result forms can also be customized to show more complicated results. There's a really neat demo present in the download that allows searching for countries and displays the flag of the countries next to the name in the result set.

0

精彩评论

暂无评论...
验证码 换一张
取 消