我正在使用此Bootstrap作为我的GUI。
我已经看到与我的问题相关的LINK。但是当我尝试@KyleMit
中的代码时,我的控制台出错了。我得到了这个Uncaught TypeError: $(...).autocomplete is not a function
当前代码
$(".autocomplete").autocomplete({
source: "/Controller/Action",
minLength: 1,
select: function (event, ui) {
if (ui.item) {
$(".autocomplete").val(ui.item.value);
}
}
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="form-group">
<label>Languages</label>
<input class="form-control autocomplete" placeholder="Enter A" />
</div>
</div>
&#13;
答案 0 :(得分:6)
检查jquery自动完成的基本示例,
JS CODE,
$( 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
});
} );
你的HTML,
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
在头标记中包含以下代码
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
您可以在此处找到jsfiddle。