jQuery autocomplete append selection to div
I'm trying 开发者_JAVA百科to insert a variable within a div (#cityInput) upon jQuery autocomplete selection. What am I doing wrong?
var options = ["California", "Seattle", "Portland", "San Francisco"];
$(function() {
$("#citySelect").autocomplete({
source: options,
minLength: 2,
select: function() {
$('#chooseCity').dialog('close');
$('#cityInput').append('airline');
},
});
});
You have an extra comma:
},
^
For one thing, you have comma after the last option (select
).
That probably gives your javascript error. (I would recommend some tool, like firebug, for monitoring errors in javascript)
edit
Here's a live example. I enter Se
in input, click on appeared Seattle
choice and get alert with the city I selected.
Autocomplete works.
精彩评论