有这样个需求两个输入框,对应的是不同的数据,输入时要给下面生成的ul中的 li 加上对应的类名,编程语言的加上language,球员的加上player,该怎么设置autocomplete,求老司机指点下面是没有对应类名的代码<div class="ui-widget" style="float:left;"> <label for="language">语言:</label> <input id="language"></div><div class="ui-widget" style="float:left;"> <label for="palyer">球员:</label> <input id="palyer"></div>
1 回答
慕村225694
TA贡献1880条经验 获得超4个赞
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
}).data("ui-autocomplete")._renderItem = function (ul, item) {
ul.addClass('customClass'); //Ul custom class here
return $("<li></li>")
.addClass("liCustomClass") //item based custom class to li here
.append("<a href='#'>" + item.label + "</a>")
.data("ui-autocomplete-item", item)
.appendTo(ul);
};
添加回答
举报
0/150
提交
取消