-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (26 loc) · 933 Bytes
/
index.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
const viewSection = ({target}) => {//{target}) => {
const sections = document.querySelectorAll('.sections>*')
const sectionId = (target.href).split('#')[1]
for(i=0;i<sections.length;i++) {
sections[i].classList.remove('active')
if(sections[i].id == sectionId) {
sections[i].classList.add('active')
}
}
}
const closesSections = () => {
const sections = document.querySelectorAll('.sections>*')
for(i=0;i<sections.length;i++) {
sections[i].classList.remove('active')
}
}
const aboutButton = document.querySelector('[href="#about"]')
const servicesButton = document.querySelector('[href="#services"]')
const hireButton = document.querySelector('[href="#hire-form"]')
aboutButton.onclick = viewSection
servicesButton.onclick = viewSection
hireButton.onclick = viewSection
const closeButtons = document.getElementsByClassName('close')
for(i=0;i<closeButtons.length;i++) {
closeButtons[i].onclick = closesSections
}