simple code here am trying for auto suggestion
this is my autosuggestion code for written in .js file (inside (document).ready function)
$(function () {
var list = [
"One",
"two",
"Three",
"Four",
];
debugger;
$("#text").autocomplete({
minLength: 0,
delay: 0,
placeholder: "Select Transporter...",
source: list
});
html code
<input type="text" id="text" value="text" />
error showing as :
Uncaught TypeError: Cannot read properties of undefined (reading 'length')
not able to see any moves.after entering somthing then when i come out of textbox . this above error comes in console please help me out . and share link where i can learn and implement about auto-sugestion
CodePudding user response:
From https://jqueryui.com/autocomplete/ make sure you imported these two CDN
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
final code would like this
<!doctype html>
<html>
<head>
<title>Online jQuery Editor</title>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
</head>
<body>
<input type="text" id="text" value="text" />
</body>
<script>
$(document).ready(function () {
$(function () {
var list = [
"one",
"two",
"three",
"four",
];
debugger;
$("#text").autocomplete({
minLength: 0,
delay: 0,
placeholder: "Select Transporter...",
source: list
});
})
});
</script>
</html>