设置光标在ui-autocomplete-input上自动闪烁,然后选择输入jQuery

问题描述

有人可以帮助如何在选择输入之前在jQuery的ui-autocomplete-input上自动设置光标闪烁。我浏览了文档https://api.jqueryui.com/autocomplete/,但没有找到答案。我只找到了这个$(“ .selector”).autocomplete(“ search”,“”);会自动触发搜索(选择选项列表),但是我只需要闪烁光标而无需触发选择选项列表。

解决方法

使用javascript(jquery):

$(element).focus(); //you can use $("textarea") for a more generic 
//do autocomplete stuff after

(如果您在页面加载中使用自动完成功能)使用纯html:

<input type="text" id="fname" name="fname" autofocus>
<!--the "autofocus" makes elements come in focus on page load-->

*关于w3schoolStackoverfow的具体说明

*这很骇人! :)
*一次只能保持一个要素集中。

希望我能帮上忙!