【问题标题】:Set default value in the searchable dropdown menu在可搜索的下拉菜单中设置默认值
【发布时间】:2020-10-12 13:50:23
【问题描述】:

我想将Egypt 设置为可搜索下拉菜单中的默认值。目前没有设置值。这是Jsfiddle 链接

我尝试这样设置,它将默认值设置为Egypt,但是当我打开列表时,Egypt 没有在列表中突出显示

$(document).ready(function(){
    $("#search-countires").val("Egypt");
});

【问题讨论】:

    标签: javascript jquery drop-down-menu dropdown


    【解决方案1】:

    您可以将值字段添加到输入元素。

    检查以下fiddle

    <input type="text" placeholder="search countries" id="search-countires" onkeyup="filterFunction(this,event)" value="Egypt">
    

    【讨论】:

    • 它没有用。当我打开列表时,埃及没有突出显示
    【解决方案2】:

    添加 .change()

    $(document).ready(function(){
        $("#search-countires").val("Egypt").change();
    });
    

    【讨论】:

    • 它没有用。当我打开列表时,埃及没有突出显示
    猜你喜欢
    • 2018-09-29
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 2019-09-25
    相关资源
    最近更新 更多