-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.js
21 lines (17 loc) · 803 Bytes
/
search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const search = document.getElementById('search'); const nav = document.getElementById('nav'); const links = nav.getElementsByTagName('a');
search.addEventListener('keyup', function() { const query = search.value.toLowerCase();
for (let i = 0; i < links.length; i++) { const text = links[i].textContent.toLowerCase();
if (text.includes(query)) {
links[i].style.display = 'block';
} else {
links[i].style.display = 'none';
}
} });
document.addEventListener("DOMContentLoaded", function() {
const searchInput = document.querySelector('.form-control');
searchInput.style.width = "150px";
searchInput.style.height = "25px";
searchInput.style.fontSize = "12px";
searchInput.style.padding = "3px 6px";
searchInput.style.borderRadius = "3px";
});