单击 jQuery 自动完成查看所有内容? [英] jQuery autoComplete view all on click?
本文介绍了单击 jQuery 自动完成查看所有内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在以一种相对简单的方式使用 jQuery 的自动完成功能:
I'm using jQuery's autocomplete in a relatively simple way:
$(document).ready(function() {
var data = [ {text: "Choice 1"},
{text: "Choice 2"},
{text: "Choice 3"} ]
$("#example").autocomplete(data, {
matchContains: true,
minChars: 0,
formatItem: function(item)
{ return item.text; }
}
);
});
如何添加将显示自动完成的所有可用选项的 onclick 事件(如按钮或链接)?基本上,我希望混合自动完成和选择/下拉元素.
How do I add an onclick event (like a button or a link) that will display all the available choices for the autocomplete? Basically I'm looking to make a hybrid of an autocomplete and a select/dropdown element.
谢谢!
推荐答案
我在文档中看不到明显的方法,但您尝试在启用自动完成的文本框上触发焦点(或单击)事件:
I can't see an obvious way to do that in the docs, but you try triggering the focus (or click) event on the autocomplete enabled textbox:
$('#myButton').click(function() {
$('#autocomplete').trigger("focus"); //or "click", at least one should work
});
这篇关于单击 jQuery 自动完成查看所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文