Skip to content

Instantly share code, notes, and snippets.

@codingwithsara
Created November 9, 2018 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingwithsara/fba2fee8a0136117fc97c75f355beebb to your computer and use it in GitHub Desktop.
Save codingwithsara/fba2fee8a0136117fc97c75f355beebb to your computer and use it in GitHub Desktop.
jQuery UI Tutorial - Auto Complete Form -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Auto Complete</title>
<style>
.container {
margin: 100px auto;
text-align: center;
}
#inputField {
width: 300px;
height: 40px;
font-size: 18px;
}
</style>
</head>
<body>
<div class="container">
<h2>Auto Complete Form</h2>
<input type="text" id="inputField">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
$(function(){
var data = [
"Cake - Banana",
"Cake - Carrot",
"Cake - Strawberry",
"Candy - Apple",
"Candy - Orange",
"Candy - Strawberry",
"Juice - Apple",
"Juice - Carrot",
"Juice - Grape",
"Juice - Orange"
];
$("#inputField").autocomplete({
source:data
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment