-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (21 loc) · 1.09 KB
/
script.js
File metadata and controls
43 lines (21 loc) · 1.09 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
40
41
42
43
const search = ()=>{
// WE have converted to lower case so that there is no problem when search is applied in capitalixed or uncaitalized or any other case
var filter = document.getElementById('searchInput').value.toLowerCase();
var list= document.getElementsByTagName('li')
var headings= document.getElementsByTagName('h2')
var headingIntro=document.getElementsByClassName('heading-intro')
var codebox= document.querySelectorAll('.code')
for (let index = 0; index < headings.length; index++) {
// INNER text of headings
let innerTextHeadings=headings[index].innerText;
let heading_INTRODUCTION=headingIntro[index].innerText;
// Checking if the searched string is present in the headings.innerText
if (innerTextHeadings.toLowerCase().indexOf(filter)>-1 || heading_INTRODUCTION.toLowerCase().indexOf(filter)>-1) {
//When string is present the +ve index is
list[index].style.display="none";
} else {
// If string is not present then the index is -1
list[index].style.display="none";
}
}
}