<input class ="metro" type="text" name="city">
This is input tag as a child of which I need to append an unordered list which is passed as an array to a function call as follows
$("input").autoComplete(["agra","bombay","delhi","chennai"]);
This autocomplete function accepts an array and outputs its elements as an unorederd list which I am not able to do.
$("input").autoComplete({source:["agra","bombay","delhi","chennai"]});
If you want to implement the function on your own, the basic block would be as follows
$(function () {
var Cities = [
"agra",
"bombay",
"delhi",
"chennai"
];
$("input.metro").autocomplete({
$(this).append("<ul>");
for(i=0;i<Cities.length;i++){
$(this).children("ul").append("<li>Cities[i]</li>");
}
$(this).append("</ul>");
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.