本文介绍了JQuery AutoComplete,手动选择第一个搜索项并绑定点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想手动选择自动填充中的项目并在给定值的情况下点击它。

I want to manually select an item in autocomplete and click it given the value.

以下代码:

autocompleteitem.autocomplete("option", "autoFocus", true).autocomplete("search", autocompleteitem.val());

autocompleteitem是一个输入对象,包含我想要搜索的值。现在,此代码成功从下拉列表中选择第一个项目,但它没有单击它。我不想自己点击它我希望它以某种方式在该代码中发生。

autocompleteitem is an object of input that holds the value i want to search for. Now this code successfully selects the first item from drop down but it does not click on it. I do not want to click on it myself i want it to happen somehow in that code.

我尝试了上面代码的以下添加功能:

I tried the following additions to the code above which didnt work:

   .click(), .select(), .trigger('select'), .find('a').click(), .change()

有什么方法可以做到吗?

is there any way i can do it?

谢谢

请有人帮忙

推荐答案

看看这个 jqFAQ.com 主题,这将帮助您以编程方式选择值的第一个匹配选项并将其设置为自动完成文本框。还有其他几个与自动填充相关的常见问题解答,我认为这可能对您有用。

Take a look at this jqFAQ.com topic, this will help you to programatically pick the first matching option for a value and set it into the autocomplete textbox. There are few other autocomplete related faqs too, i think that may be useful for you.

这篇关于JQuery AutoComplete,手动选择第一个搜索项并绑定点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 17:04