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 theavailableTagsarray as the source of the suggestions.
For more information, see the jQuery UI Autocomplete documentation.
More of Jquery
- How do I use jQuery to zip files?
- How do I set the height of an element using jQuery?
- How can I use JQuery with Yii2?
- How do I use jQuery to zoom in or out on an element?
- How do I use jQuery ZTree to create a hierarchical tree structure?
- How can I get the y position of an element using jQuery?
- How can I parse XML data using jQuery?
- How do I use jQuery to validate a form?
- How can I use jQuery to select elements with an XPath expression?
- How do I use a jQuery UI Slider?
See more codes...