单击时会弹出jQuery自动完成功能

时间:2013-07-08 04:04:19

标签: jquery

我想使用这个jQuery自动完成插件,但我想在点击输入框时弹出所有标签。有什么方法可以让它在点击时显示所有标签,而不是等待输入和查看匹配。

<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( ".tags" ).autocomplete({
source: availableTags
});
});
</script>

<div class="ui-widget">
<input  class="tags" />
</div>

1 个答案:

答案 0 :(得分:2)

尝试使用自动填充功能绑定focus

$(".tags").autocomplete({
        source: availableTags,
        minLength: 0
    }).bind('focus', function () {
        $(this).autocomplete("search");
    });

查看此JSFiddle