-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (26 loc) · 832 Bytes
/
script.js
File metadata and controls
30 lines (26 loc) · 832 Bytes
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
var questions = document.getElementsByClassName("question");
var searchQuestion = document.getElementById("searchFAQ");
var searchInput;
var thisQuestion;
for (i = 0; i < questions.length; i++) {
questions[i].addEventListener("click", function() {
this.classList.toggle("active");
var answer = this.nextElementSibling;
if (answer.style.maxHeight) {
answer.style.maxHeight = null;
} else {
answer.style.maxHeight = answer.scrollHeight + "px";
}
});
}
function SearchingFAQ() {
searchInput = searchQuestion.value.toUpperCase();
for (i = 0; i < questions.length; i++) {
thisQuestion = questions[i].textContent;
if (thisQuestion.toUpperCase().indexOf(searchInput) > -1) {
questions[i].classList.remove("hide");
} else {
questions[i].classList.add("hide");
}
}
}