-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.js
58 lines (50 loc) · 1.78 KB
/
card.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
/*var cards_btn_front = document.getElementsByClassName("btn-card-front");
var cards_btn_back = document.getElementsByClassName("btn-card-back");
var cards_front = document.getElementsByClassName("front");
var cards_back = document.getElementsByClassName("back");
var card_no;
function flipCardBack(e) {
for(var i=1;i<=cards_btn_front.length;i++) {
if(e.target.classList[3] == ("btn-" + i)) {
card_no = i;
break;
}
}
cards_front[card_no-1].style.display = "none";
cards_back[card_no-1].style.display = "block";
}
function flipCardFront(e) {
for(var i=1;i<=cards_btn_back.length;i++) {
if(e.target.classList[3] == ("btn-" + i)) {
card_no = i;
break;
}
}
cards_front[card_no-1].style.display = "block";
cards_back[card_no-1].style.display = "none";
}
for(var i=0;i<cards_btn_front.length;i++) {
cards_btn_front[i].addEventListener("click", flipCardBack);
cards_btn_back[i].addEventListener("click", flipCardFront);
}*/
var dots = document.getElementsByClassName("dots");
var more = document.getElementsByClassName("read-more");
var btn = document.getElementsByClassName("btn-more-less");
function readMoreLess(e) {
var clicked_card = e.currentTarget.getAttribute("data-button-more-less");
btnText = btn[clicked_card];
moreText = more[clicked_card];
dots_card = dots[clicked_card];
if (dots_card.style.display === "none") {
dots_card.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
}
else {
dots_card.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
for(var i=0;i<btn.length;i++)
btn[i].addEventListener("click", readMoreLess);