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 ZTree to create a hierarchical tree structure?
- How do I use jQuery to zip files?
- How do I download a zip file using jQuery?
- How do I use jQuery to change the z-index of an element?
- How do I use a jQuery x-csrf-token?
- How do I add a zoom feature to my website using jQuery?
- How do I use jQuery to zoom an image when it is clicked?
- How can I use JQuery with Yii2?
- How can I convert XML data to JSON using jQuery?
- How do I prevent XSS attacks when using jQuery?
See more codes...