An autocomplete input field to enable users quickly finding and selecting some value, leveraging searching and filtering.
By giving an autocompleted field focus or entering something into it, the plugin starts searching for matching entries and displays a list of values to choose from. By entering more characters, the user can filter down the list to better matches.
This can be used to enter previous selected values, eg. for tags, to complete an address, eg. enter a city name and get the zip code, or maybe enter email addresses from an addressbook.
Both local and remote data can be used: Local is good for small datasets (like an addressbook with 50 entries), remote is necessary for big datasets, like a database with hundreds or millions of entries to select from.
A simple autocompleted input, with the jQuery API Reference as data.
Code:
var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities". split ( "");
$ ( "# example"). autocomplete (data);
Code:
<! DOCTYPE HTML PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src = "http://code.jquery.com/jquery-latest.js"> </ script> <link rel = "stylesheet" href = "http://dev.jquery.com/view/trunk/plugins/autocomplete/ demo / main.css "type =" text / css "/> <link rel =" stylesheet "href =" http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css "type = "text / css" /> <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js"> < / script> <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js"> </ script> <script type = "text / javascript" src = "http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js"> </ script> <script> $ (document). ready (function () (var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities". split ( ""); $ ( "# example"). autocomplete (data);)) </ script> </ head> <body> API Reference: <input id="example" /> (try "C" or "E") </ body> </ html>
Bookmarks