jQuery select2插件如何仅获取结果"myString%" [英] jquery select2 plugin how to get only the result 'myString%'
本文介绍了jQuery select2插件如何仅获取结果"myString%"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jquery-select2插件,但我想知道如何仅获取以typed关键字开头的结果(例如'myString%')
i'm using the jquery-select2 plugin but i'm wondering how can i get only results that begins with the typed keyword ( like 'myString%')
推荐答案
实际上文档提供了一个示例:
The documentation actually provides an example for that:
$("select").select2({
matcher: function(term, text) {
return text.toUpperCase().indexOf(term.toUpperCase())==0;
}
});
上面的匹配器不区分大小写,为了区分大小写,请删除两个.toUpperCase()
调用.
The above matcher is case-insensitive, for case-sensitive remove both .toUpperCase()
calls.
这篇关于jQuery select2插件如何仅获取结果"myString%"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文