我有一個輸入欄和一個隱藏的div。輸入是隻讀的。當用戶點擊輸入時,使用JQuery UI自動完成提出項目列表。我想和不能實現的是當用戶從列表中選擇一個項目時觸發一個事件(刪除隱藏的類)。希望有人能幫忙。預先感謝您的回覆。乾杯。馬克。JQuery UI自動完成 - 如何選擇項目時觸發事件?
我的HTML:
<input id="conditions" type="text" readonly="readonly" /input>
<div id="test" class="hidden">some text</div>
我的CSS:
input{
margin:50px;
border:1px solid black;}
div{
width:200px
height:200px;
background-color:orange;}
.hidden{
display:none;}
我的JS:
$(function() {
var availableTags = [
"aucune","Prise de contact préalable nécessaire"
];
$("#conditions").autocomplete({
source: availableTags,
minLength: 0
}).click(function() {
$(this).val("");
$(this).autocomplete("search");
});
});
您的minLength後'缺少一個逗號:0' – shanabus 2012-03-05 15:29:22
這就是它!非常感謝... – Marc 2012-03-05 15:30:18
@shanabus謝謝,我已經更新了答案。 – freakish 2012-03-05 15:30:25