gpt4 book ai didi

jquery-select2 - 选择2清除 'x'按钮来设置默认值?

转载 作者:行者123 更新时间:2023-12-02 21:15:27 24 4
gpt4 key购买 nike

是否可以在启用 allowClear 的情况下按 Select2 下拉菜单上的“x”按钮设置默认(预定义)值?

最佳答案

Select2 允许您将占位符与空字符串以外的 ID 相关联。

$("select").select2({
placeholder: {
id: "the_predefined_value",
text: "The placeholder text"
}
});

因此,当您单击“x”时,它会将值设置为 the_predefined_value并显示占位符文本。您将需要一个 <option>valuethe_predefined_value为了使其发挥作用。

关于jquery-select2 - 选择2清除 'x'按钮来设置默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30975321/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com