我有一个用 JQuery UI 自动完成填充的输入字段。目的是检查数据库中是否已存在该值。
当选择存在时,会显示#warning div :
$("#item").autocomplete({
source: function(request, response) {
$.getJSON(
"search.php",
{ term:request.term, type:'item' },
response
);
},
minLength: 3,
select: function(event, ui) {
$("#warning").show();
$("#item").html('');
}
我希望在用户选择条目但添加一些字符时隐藏#warning div。
我不知道该怎么做。
感谢您的帮助。
最佳答案
通过在调用自动完成时简单地添加一个 hide() 函数来解决:
$("#item").autocomplete({
source: function(request, response) {
$.getJSON(
"search.php",
{ term:request.term, type:'item' },
response
);
$("#warning").hide();
},
minLength: 3,
select: function(event, ui) {
$("#warning").show();
$("#item").html('');
}
关于JQuery UI 自动完成,在输入字段中键入更多字符时隐藏 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55731804/