我如何在用空格分隔的所有单词中使jquery自动完成搜索 [英] How can I make jquery autocomplete search in all the words seperated by a whitespace

查看:65
本文介绍了我如何在用空格分隔的所有单词中使jquery自动完成搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设在jQuery自动完成源中,我有一个像SELINA RISEWA MIL的词.

Suppose in the source of jQuery autocomplete I have a word like SELINA RISEWA MIL.

但是,如果我输入SELINA MIL,则jQuery自动完成功能不会返回该选项.我该如何更改?

But if I type SELINA MIL jQuery autocomplete doesn't return that option. How can I change that?

推荐答案

您可以使用正则表达式-这样说

You can use Regular Expressions-- say like this

        $('#elem').autocomplete({
            source: function(request, response) {
                var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term, ""));
                var data = $.grep( array, function(value) {
                    return matcher.test( value.label || value.value || value );
                });
                response(data);
            }
        });

这篇关于我如何在用空格分隔的所有单词中使jquery自动完成搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆