我正在尝试显示输入的搜索词的最佳匹配。例如
现在 Jquery 没有给我想要的效果。当我输入:one today时,自动完成不会显示任何内容,但如果我输入一天,它将按顺序显示以这两个单词开头的搜索结果。我希望今天出现的一天是今天的第一个和最后一个。我希望搜索结果显示其中包含这些单词的顺序并不重要。我浏览过这里并没有找到类似的东西,这似乎是一种常见的搜索方法,我不明白为什么没有人问过这个问题。有没有内置的方法来处理这个?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
var availableTags = [
"one day is the first and last today" , "tuesday is today" , "one" , "one day is tomorrow"
];
$( "#tags" ).autocomplete({
source: availableTags, multiple: true,
mustMatch: false
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" />
</div>
</body>
</html>