forked from Pixabay/JavaScript-autoComplete
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestcase.html
More file actions
39 lines (33 loc) · 1 KB
/
Copy pathtestcase.html
File metadata and controls
39 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="./auto-complete.css">
</head>
<body>
<div class="ac" id="ac">
<input type="text">
</div>
<script src="./auto-complete.js"></script>
<script>
debugger;
var acBase = ['car', 'cat', 'camera'];
var ac = new autoComplete({
selector: '.ac input',
minChars: 2,
source: function(term, suggest){
term = term.toLowerCase();
var choices = acBase;
var matches = [];
for (i=0; i<choices.length; i++)
if (~choices[i].toLowerCase().indexOf(term)) matches.push(choices[i]);
suggest(matches);
},
selectorToInsert: '.ac'
});
</script>
</body>
</html>