gpt4 book ai didi

jquery - 如何获取 jquery 自动完成值进行搜索?

转载 作者:行者123 更新时间:2023-12-01 04:53:21 25 4
gpt4 key购买 nike

自动完成部分可以工作,但单击下拉列表中的值只会将它们放入搜索框中,然后我必须按 Enter 才能执行搜索。如何获取要搜索的值?

<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">

<script>
$(function() {
var availableTags = [
"SEO",
"Responsive Design",
"Google Local",
"Twitter",
"Social Media",
"Web Design",
"What is Google Authorship",
"NFL",
"Fantasy Football Rankings",
"Kevin Sullivan",
"Fantasy Football RB Rankings 2013",
"Fantasy Football",
"How to Buy Twitter Followers",
"Advanced IFX",
"Social Media Marketing",
"NFL Schedule 2013-2014 Season",
"Fantasy Football Breakdown",

];
$(".search_box").autocomplete({
source: availableTags,
select: function(event, ui) {
$(".search_box").val(ui.item.value);
$("#search").submit();
});
});
</script>

最佳答案

我认为这就是您正在寻找的:

$(".search_box").autocomplete({
source: availableTags,
select: function(event, ui) {
$(".search_box").val(ui.item.value);
$("form").submit();
}
})

更改“表单”以选择您要提交用于搜索的特定表单。这将用您单击的任何值填充搜索框,然后自动提交搜索表单。

这是一个可以用来测试的 jsfiddle:http://jsfiddle.net/4gArf/

关于jquery - 如何获取 jquery 自动完成值进行搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17018635/

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