我有一个应用程序,用户输入一个单词并出现一个自动完成。When the select the appropriate autocomplete, it's added to the input
field and the user keeps typing. 我非常想在输入框中突出显示该单词(而不是在自动完成列表中),并且不突出显示框中的其余单词,但我找不到任何示例。
$(searchBoxId).autocomplete({
source: keys,
delay: 0,
selectFirst: true,
select: function(event, ui) {
var TABKEY = 9;
this.value = ui.item.value;
if (event.keyCode == TABKEY) {
event.preventDefault();
this.value = this.value + " ";
// XXX something goes here?
this.focus();
}
return false;
},
autoFocus: true,
minLength: 2
});
这是 jquery 1.8.20。通过“突出显示”,我的意思是“能够以类似于 Facebook 或 Google+ 突出显示用户名的方式使其在视觉上看起来与众不同”。