$(ui-autocomplete li a ).text(
isn t comparing any one>lement, or each of them individual, but this consider contenate all potential, so that at the time You ve打上了“gho”的比较:
if ("gho" == "ghost riderghost huntersghost rider 2ghost adventuresghost rider spirit of vengeanceghanaghbghetto hikesghostbusters 3ghost") {
}
另一个性质相同的问题是:
$( .ui-autocomplete li a ).css("font-weight", "normal");
will change the style for all found matches. Neither behaviour isn t what you want, I suspect.
你们可能想要的是:
$("#input").on( keyup , function(e){
var val = $( #input ).val();
$.each($( .ui-autocomplete li a ), function() {
if (val == $(this).text()) {
$(this).css("font-weight", "normal");
}
});
});