我希望每当用户点击表单输入时,都会显示默认的选项列表,例如Refer practo
点击专业,医生诊所等。我该怎么做?
答案 0 :(得分:0)
答案 1 :(得分:0)
$( "#tags" )
.autocomplete({
source: availableTags
}).on('focus', function(){ $(this).autocomplete("instance").search("a"); } );
将代替"自动完成("搜索")" 完整代码低于
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" )
.autocomplete({
source: availableTags
}).on('focus', function(){ $(this).autocomplete("instance").search("a"); } );
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Anshu: </label>
<input id="tags";>
</div>
</body>
</html>