-
Notifications
You must be signed in to change notification settings - Fork 2
/
page3_news.js
67 lines (57 loc) · 2.13 KB
/
page3_news.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
const allButton = document.querySelector(".all-button");
const technoButton = document.querySelector(".techno-button");
const socialButton = document.querySelector(".social-button");
const securityButton = document.querySelector(".security-button");
const financeButton = document.querySelector(".finance-button");
const technoArticles = document.querySelectorAll(".techno");
const socialArticles = document.querySelectorAll(".social");
const securityArticles = document.querySelectorAll(".security");
const financeArticles = document.querySelectorAll(".finance");
function hidden(item) {
item.classList.toggle("hidden");
}
function visible(item) {
item.classList.remove("hidden");
}
technoButton.addEventListener("click", function () {
socialArticles.forEach(visible);
securityArticles.forEach(visible);
financeArticles.forEach(visible);
technoArticles.forEach(visible);
socialArticles.forEach(hidden);
securityArticles.forEach(hidden);
financeArticles.forEach(hidden);
});
socialButton.addEventListener("click", function () {
socialArticles.forEach(visible);
securityArticles.forEach(visible);
financeArticles.forEach(visible);
technoArticles.forEach(visible);
technoArticles.forEach(hidden);
securityArticles.forEach(hidden);
financeArticles.forEach(hidden);
});
securityButton.addEventListener("click", function () {
socialArticles.forEach(visible);
securityArticles.forEach(visible);
financeArticles.forEach(visible);
technoArticles.forEach(visible);
technoArticles.forEach(hidden);
socialArticles.forEach(hidden);
financeArticles.forEach(hidden);
});
financeButton.addEventListener("click", function () {
socialArticles.forEach(visible);
securityArticles.forEach(visible);
financeArticles.forEach(visible);
technoArticles.forEach(visible);
technoArticles.forEach(hidden);
socialArticles.forEach(hidden);
securityArticles.forEach(hidden);
});
allButton.addEventListener("click", function () {
socialArticles.forEach(visible);
securityArticles.forEach(visible);
financeArticles.forEach(visible);
technoArticles.forEach(visible);
});