I get a JavaScript error in Firefox when using the jQuery autocomplete function on a HTML input field. " $('#geosearch').autocomplete is not a function
" Using Firebug I can see that the jQuery attribute of the input field $('#geosearch')
is set to "1.11.0" which means that the version of jQuery I am using should load the autocomplete function.
Here is the html code I am using :
<div class="panel">
<label for="geosearch">Geographic search: </label>
<input id="geosearch">
</div>
Here is the javascript code I am using :
$('#geosearch').autocomplete({
source: [ "a", "b", "c"],
minLength: 2,
select: function( event, ui ) {
alert(ui.item ?"Selected: "+ui.item.value+"aka "+ui.item.id :"Nothing selected, input was " + this.value);
}
});
I created jsfiddle for you check
Jquery:
$(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
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.