jqueryHow do I use jQuery UI Autocomplete?
jQuery UI Autocomplete is a widget which provides users with a list of suggestions, as they type, from which they can select an item. It is an easy way to enable users to quickly find and select from a list of values as they type.
The following example shows how to use jQuery UI Autocomplete:
$(document).ready(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
This example code will create a textbox with an autocomplete feature. As the user types, a list of suggestions will appear from the availableTags
array.
Code explanation
-
$(document).ready(function() {
: This code part ensures that the code is executed after the DOM is fully loaded. -
var availableTags = [ ... ];
: This code part creates an array of strings which will be used as the source of the autocomplete suggestions. -
$("#tags").autocomplete({ ... });
: This code part initializes the autocomplete widget and sets theavailableTags
array as the source of the suggestions.
For more information, see the jQuery UI Autocomplete documentation.
More of Jquery
- How can I get the y position of an element using jQuery?
- How do I create a jQuery Yes/No dialog?
- How do I decide which one to use when comparing jQuery and React for software development?
- How do I use a jQuery zoom plugin?
- How can I use jQuery to yield a result?
- How can I use jQuery to check if an element is visible?
- How do I unbind an event listener in jQuery?
- How do I use a jQuery UI Slider?
- How can I make a jQuery XMLHttpRequest?
See more codes...