gpt4 book ai didi

JQuery UI 显示由 focus() 事件触发的自动完成列表

转载 作者:行者123 更新时间:2023-12-01 03:54:00 24 4
gpt4 key购买 nike

我想显示由 focus() 事件触发的自动完成列表,但看起来只有当我第一次关注“id”文本框,然后我关注“id2”文本框时它才有效,并将焦点重新放在“id”文本框上,我的自动完成列表将不会显示,有什么原因吗?

<link media="all" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script>

<script type="text/javascript">
$(function() {
$('#id').autocomplete({
source: ["ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
],
minLength: 0
});

$('#id').focus(function(){
$(this).trigger('keydown.autocomplete');
});
});
</script>


<input type="text" id="id">

<input type="text1" id="id2">
<小时/>

我想显示由 focus() 事件触发的自动完成列表,但看起来只有当我第一次关注“id”文本框,然后我关注“id2”文本框时它才有效,并将焦点重新放在“id”文本框上,我的自动完成列表将不会显示,有什么原因吗?

<script type="text/javascript">
$(function() {
$('#id').autocomplete({
source: ["ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
],
minLength: 0
});

$('#id').focus(function(){
$(this).trigger('keydown.autocomplete');
});
});

最佳答案

尝试使用

$(this).autocomplete("search")

而不是

$(this).trigger('keydown.autocomplete')

关于JQuery UI 显示由 focus() 事件触发的自动完成列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4952295/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com