javascript 可搜索下拉菜单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21332545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 20:40:12 来源:igfitidea点击:
Searchable Dropdown
提问by user3224577
In the below code there is a dropdown which has countries and my aim is to make the dropdown to be editable and searchable.Please help me to do this.
在下面的代码中有一个包含国家/地区的下拉列表,我的目标是使下拉列表可编辑和搜索。请帮助我做到这一点。
code:
代码:
<label for='SelectCountry'>Choose a country:</label><br /><br />
<asp:DropDownList id='SelectCountry' name='SelectCountry' runat='server'
ClientIDMode='Static'>
<asp:ListItem Text='Afghanistan' Value='Afghanistan'></asp:ListItem>
<asp:ListItem Text='Albania' Value='Albania'></asp:ListItem>
<asp:ListItem Text='Algeria' Value='Algeria'></asp:ListItem>
<asp:ListItem Text='Bahrain' Value='Bahrain'></asp:ListItem>
<asp:ListItem Text='Bangladesh' Value='Bangladesh'></asp:ListItem>
<asp:ListItem Text='Barbados' Value='Barbados'></asp:ListItem>
<asp:ListItem Text='Cambodia' Value='Cambodia'></asp:ListItem>
<asp:ListItem Text='Cameroon' Value='Cameroon'></asp:ListItem>
<asp:ListItem Text='Canada' Value='Canada'></asp:ListItem>
</asp:DropDownList>
<br/>
<script type='text/javascript' >
$(function () {
$('#SelectCountry').ufd({ log: true });
});
</script>
</asp:Content>
回答by 124
Select2
is a jquery plugin that gives facilities like searching and displaying image, just check this link: Select2 - DropDown
Select2
是一个 jquery 插件,提供搜索和显示图像等功能,只需查看此链接: Select2 - DropDown