这似乎是一个非常简单的想法,但我不知道如何从 select2 下拉列表中过滤掉原始选择的选项标签。
基本上,这是:
<select id="select">
<option class="car">Car 1</option>
<option class="plane">Plane 1</option>
</select>
$("#select").select2();
...应该创建一个仅包含 car
类选项标签的假选择。
最佳答案
OP 似乎在 https://github.com/select2/select2/issues/1048 找到了答案.
答案是提供一个 matcher
功能。
$("#select").select2({
matcher: function(term, text, option) {
return option.hasClass('car');
}
});
关于javascript - 如何使用 Select2 从原始选择中过滤掉选项标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15444560/