-
Notifications
You must be signed in to change notification settings - Fork 2
/
event.js
48 lines (37 loc) · 1.16 KB
/
event.js
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
44
45
46
47
48
//Modal box for Contact us
var modalBox = document.getElementById("myModal");
document.getElementById("contact").onclick= contactinfo;
document.getElementById("close").onclick= closeModal;
function contactinfo(){
modalBox.style.display = "block";
}
function closeModal() {
modalBox.style.display = "none";
}
//drop down list for Services
var service = document.getElementById("service");
var myDropdown = document.getElementById("myDropdown");
service.onclick= dropdown;
function dropdown() {
myDropdown.classList.toggle("show");
}
//if user clicks away close the pop up
window.onclick = function(event) {
if (event.target == modalBox) {
modalBox.style.display = "none";
}
if (!event.target == service) {
if(myDropdown.classList.contains('show')) {
myDropdown.classList.remove('show');
}
}
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(e) {
if (!e.target.matches('#service')) {
var myDropdown = document.getElementById("myDropdown");
if (myDropdown.classList.contains('show')) {
myDropdown.classList.remove('show');
}
}
}