-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
80 lines (66 loc) · 3.36 KB
/
app.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const bookModal = (e) => {
console.log(e.target.id || e.target.className)
if (e.target.id === 'book-now' || e.target.id === 'modal-close' || e.target.id === 'book-now-landing-button') {
console.log(`The element ID is ${e.target.id}`)
if (document.getElementById('book-modal').style.display === 'block' || null || undefined) {
document.getElementById('book-modal').style.display = 'none'
} else document.getElementById('book-modal').style.display = 'block';
}
}
const citySelector = (e) => {
console.log(e.target.id || e.target.className)
if (e.target.id === 'country'){
console.log(`The country is ${e.target.value}`)
switch (e.target.value) {
case 'colombia':
document.getElementById('colombia').style.display = 'block'
document.getElementById('town-selector').style.display = 'block'
document.getElementById('ecuador').style.display = 'none'
document.getElementById('mexico').style.display = 'none'
document.getElementById('us').style.display = 'none'
break;
case 'ecuador':
document.getElementById('ecuador').style.display = 'block'
document.getElementById('town-selector').style.display = 'block'
document.getElementById('colombia').style.display = 'none'
document.getElementById('mexico').style.display = 'none'
document.getElementById('us').style.display = 'none'
break;
case 'mexico':
document.getElementById('mexico').style.display = 'block'
document.getElementById('town-selector').style.display = 'block'
document.getElementById('colombia').style.display = 'none'
document.getElementById('ecuador').style.display = 'none'
document.getElementById('us').style.display = 'none'
break;
case 'us':
document.getElementById('us').style.display = 'block'
document.getElementById('town-selector').style.display = 'block'
document.getElementById('colombia').style.display = 'none'
document.getElementById('ecuador').style.display = 'none'
document.getElementById('mexico').style.display = 'none'
break;
default:
console.log('select a country')
document.getElementById('town-selector').style.display = 'none'
}
}
}
// document.body.insertAdjacentHTML('beforebegin', '<div id="book-modal" class="modal-box"><div class="modal-content"><h1>Some text</h1></div></div>')
// const testFunction = (e) => {
// document.getElementById('book-now').remove;
// if (e.target.id === 'book-now') {
// console.log(`The element ID is ${e.target.id}`)
// document.body.insertAdjacentHTML('afterbegin', '<div id="book-modal" class="modal-box"><div class="modal-content"><h1>Some text</h1></div></div>')
// }
// if (e.target.id !== 'book-now') {
// document.getElementById('book-now').remove;
// console.log(e.target.id || e.target.className);
// }
// }
if (document.addEventListener) {
document.body.addEventListener('click',bookModal);
}
if (document.addEventListener) {
document.body.addEventListener('click', citySelector);
}