[英]how to append selected input value to anoter div in Ajax AutoComplete for jQuery?
hi i am using Ajax AutoComplete for jQuery
library 嗨,我正在使用Ajax AutoComplete for jQuery
库
http://www.devbridge.com/projects/autocomplete/jquery/ http://www.devbridge.com/projects/autocomplete/jquery/
there are 2 demos there . 那里有2个演示。
in the first demo (Ajax auto-suggest sample (start typing country name)) 在第一个演示中(Ajax自动建议的示例(开始输入国家/地区名称))
when you select a country from the drop down that country and a image is added to a div like this 当您从下拉菜单中选择一个国家/地区并将图像添加到div这样时
<div id="selection"><img alt="" src="/global/flags/small/ht.png"> Haiti</div>
the selected dropdown value is Haiti
how can i do this . 选择的下拉值是Haiti
我该怎么做。
i want to do this when mouse clicking
on drop-down value and also when press enter
on selected drop-down value . 我想在mouse clicking
下拉值时以及在选择的下拉值上press enter
时执行此操作。
i tried but could not think a way ................. please help :( 我试过了但是没办法.................请帮助:(
In the autocomplete
-parameters you can define an onSelect
callback. 在autocomplete
参数中,您可以定义onSelect
回调。 Add the function to change the div
with the id selection
. 添加功能以使用id selection
更改div
。 Eg: 例如:
$(>selector<).autocomplete({
...
onSelect: function(value, data) {
$('#selection').html('<img src="/global/flags/small/' + data + '.png" alt="" /> ' + value);
}
...
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.