-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
66 lines (46 loc) · 1.35 KB
/
script.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
// navbar
const navbar = document.getElementById("navbar");
window.addEventListener("scroll",function(){
if(this.scrollY > 20){
navbar.classList.add('sticky');
}
else{
navbar.classList.remove('sticky');
}
});
// menu btn
const menu = document.querySelector(".menu");
const menuBtn = document.querySelector(".menu-btn");
// list items
const lists = document.querySelectorAll('li');
// array
const listArray = Array.from(lists);
listArray.forEach((li) => {
li.addEventListener("click", () => {
menu.classList.toggle('active');
})
})
menuBtn.addEventListener("click",function(){
menu.classList.toggle('active');
});
// scroll btn
const scrollBtn = document.querySelector(".scrollBtn");
window.addEventListener("scroll",()=>{
if(window.pageYOffset > 100){
scrollBtn.classList.add('show');
}
else{
scrollBtn.classList.remove('show');
}
})
// read more read less btn
const readMore =document.querySelector(".read-more-btn");
const texts = document.querySelector('.texts');
readMore.addEventListener('click',(e)=>{
texts.classList.toggle('show-more');
if(readMore.innerHTML === "Read more"){
readMore.innerHTML = "Read less";
}else{
readMore.innerHTML = "Read more";
}
})