我有以下完美的代码:
$("#element1").autocomplete({
source: function (request, response) {
$.ajax({
url: "https://jsonurlworks.com",
type: "GET",
data: { q: request.term },
//data: request,
success: function (data) {
response($.map(data.data, function (el) {
return {
label: el.name,
value: el.country_code,
size: el.audience_size
};
}));
}
});
},
select: function (event, ui) {
// Prevent value from being put in the input:
this.value = ui.item.label;
// Set the next input's value to the "value" of the item.
// $(this).next("input").value(ui.item.value);
$('#asize').text("("+ui.item.size+")");
event.preventDefault();
}
});
它显示了el.name的列表。我想在名字旁边添加尺寸。 例如标题(#18374),沿着这些方向。有什么建议吗?