自动完成部分有效,但单击下拉列表中的值只会将它们放入搜索框中,然后我必须按 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>