如何实现输入搜索下拉列表值

时间:2016-07-07 08:17:30

标签: javascript jquery html css drop-down-menu

以下是我实施的示例。我希望当用户提供输入时它应该与结果匹配,并且应该在键入后选择。这可以用HTML或jQuery或Javascript实现吗?提前谢谢。

var list = document.getElementById("list");     // Get the target element
var parent = list.parentNode;                   // Get its parent
var newList = generateListFromArray(array);     // Get the new one
parent.insertBefore(
    newList,                                    // Insert the new list...
    list                                        // ...before the old one
);
parent.removeChild(list);                       // Remove the old
newList.id = "list";                            // Give the new list the ID the
                                                // old one had

1 个答案:

答案 0 :(得分:0)

要实现您的目标,您可以使用Select2

之类的jquery插件

看一下演示,确保它有你想要的东西