forked from recodehive/awesome-github-profiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchsuggestions.html
41 lines (35 loc) · 1.08 KB
/
searchsuggestions.html
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
40
41
<input type="search" id="search-input" placeholder="Search tools...">
<ul id="suggestions"></ul>
<script>
const searchInput = document.getElementById('search-input');
const suggestionsList = document.getElementById('suggestions');
const suggestions = ['GitHub', 'VS Code', 'Trello', 'Debuggy', 'RescueTime', 'OWASP ZAP'];
searchInput.addEventListener('input', () => {
const value = searchInput.value.toLowerCase();
suggestionsList.innerHTML = '';
const filteredSuggestions = suggestions.filter(suggestion => suggestion.toLowerCase().includes(value));
filteredSuggestions.forEach(suggestion => {
const li = document.createElement('li');
li.textContent = suggestion;
suggestionsList.appendChild(li);
});
});
</script>
<style>
#suggestions {
list-style: none;
padding: 0;
position: absolute;
background-color: white;
width: 100%;
max-width: 600px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
}
#suggestions li {
padding: 10px;
cursor: pointer;
}
#suggestions li:hover {
background-color: #f0f2f5;
}
</style>