Build jQuery UI Autocomplete - Default functionality in JavaScript

Description

The following code shows how to build jQuery UI Autocomplete - Default functionality.

Example


<!-- Revised from demo code on http://jqueryui.com/ -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Default functionality</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<!-- w w  w.  j  a va 2 s  .  c  o  m-->
<script>
$(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
});
});
</script>
</head>
<body>

<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>

<div class="demo-description">
<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try.</p>
<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p>
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Build jQuery UI Autocomplete - Default functionality in JavaScript
Home »
  Javascript Tutorial »
    jQuery UI »
      AutoComplete
Javascript Tutorial AutoComplete
Build jQuery UI Autocomplete - Accent foldi...
Build jQuery UI Autocomplete - Categories i...
Build jQuery UI Autocomplete - Combobox in ...
Build jQuery UI Autocomplete - Custom data ...
Build jQuery UI Autocomplete - Default func...
Build jQuery UI Autocomplete - Multiple val...
Build jQuery UI Autocomplete - Scrollable r...