jquery.autocomplete 模糊查询 支持分组
Posted 单眼皮男生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery.autocomplete 模糊查询 支持分组相关的知识,希望对你有一定的参考价值。
//demo
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/styles.css"/>
<script src="js/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.mockjax.js"></script>
<script src="js/jquery.autocomplete.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var countries ={}
//分组模糊搜索
var countries ={};
var phoneNumberTeams = [‘15556785678‘, ‘15567895678‘,‘15556896789‘,‘18867891235‘,‘13856235678‘,‘1397890456‘];
var roomNumberTeams = [ ‘8888‘,‘8899‘,‘8866‘,‘8800‘,‘6688‘,‘6666‘,‘8886‘,‘6600‘];
var nameNnmberTeams = [‘郭德纲‘,‘岳云鹏‘,‘成龙‘,‘刘德华‘,‘angelababy‘,‘8古天乐‘];
var phoneNumber = $.map(phoneNumberTeams, function (team) { return { value: team, data: { category: ‘手机号‘ }}; });
var roomNumber = $.map(roomNumberTeams, function (team) { return { value: team, data: { category: ‘房间号‘ } }; });
var nameNnmber = $.map(nameNnmberTeams, function (team) { return { value: team, data: { category: ‘姓名‘ } }; });
var teams = phoneNumber.concat(roomNumber,nameNnmber);
$(‘#indentSearchAutoComplete‘).devbridgeAutocomplete({
lookup: teams,
minChars: 1,
onSelect: function (suggestion) {
$(‘#selection‘).html(‘You selected: ‘ + suggestion.value + ‘, ‘ + suggestion.data.category);
},
showNoSuggestionNotice: true,
noSuggestionNotice: ‘对不起,没有搜索结果‘,
groupBy: ‘category‘
});
</script>
<title></title>
</head>
<body>
<h2>支持分组</h2>
<p>手机号/房号/姓名</p>
<div>
<input type="text" name="country" id="autocomplete"/>
</div>
</body>
</html>
链接地址 https://www.devbridge.com/sourcery/components/jquery-autocomplete/
以上是关于jquery.autocomplete 模糊查询 支持分组的主要内容,如果未能解决你的问题,请参考以下文章
jquery 自动完成 自动补全 实时搜索 实时查询 即时搜索 即时 查询
使用 Jquery Autocomplete 处理“无结果”