-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (35 loc) · 1.1 KB
/
Copy pathscript.js
File metadata and controls
44 lines (35 loc) · 1.1 KB
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
const all = document.getElementById('all');
const breakfast = document.getElementById('breakfast');
const lunch = document.getElementById('lunch');
const shakes = document.getElementById('shakes');
const dinner = document.getElementById('dinner');
let everyItem = document.querySelectorAll(".box");
const array = Array.from(everyItem);
var buttons = [all, breakfast, lunch, shakes, dinner];
buttons.forEach(function (element) {
element.addEventListener("click", btnPress)
}
);
function btnPress (e) {
console.log("tero bau");
array.forEach(
function(element) {
element.classList.remove("show");
element.classList.add("hide");
}
)
//start of button press where everything is reset.
//for all
if (this.id == "all") {
array.forEach(
function(element) {
element.classList.add("show");
})
};
//for everthing else
let group = document.querySelectorAll(`.${this.id}`);
let array1 = Array.from(group);
array1.forEach (function(element) {
element.classList.add("show");
});
}