鉴于此示例,http://jsfiddle.net/CezarisLT/KHqQm/
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" />
</div>
$(function() {
var availableTags = ["ActionScript", "AppleScript","Asp","BASIC","C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"];
$( "#tags" ).autocomplete({
source: availableTags,
select: function( event, ui ) {
}
});
});
如何让不在自动完成源列表中的文本在按下回车键后发出警报?例如,如果我在文本区域中输入了“hello world”,但它不在选项列表中,我如何才能在按回车键后让 hello world 发出警报?