-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtn.js
More file actions
27 lines (27 loc) · 741 Bytes
/
btn.js
File metadata and controls
27 lines (27 loc) · 741 Bytes
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
class btnpair {
constructor(off, on, hd) {
this.api = {"on": on, "off": off}
this.onbtn = $(".on");
this.offbtn = $(".off")
this.headline = $("h1")
this.onbtn.on("click", () => {
this.on()
})
this.offbtn.on("click", () => {
this.off()
})
this.headline.html(hd)
}
async on() {
this.headline.css("color", "#EEE")
return fetch(this.api.on).then(() => {
this.headline.css("color", "#FFF")
})
}
async off() {
this.headline.css("color", "#EEE")
return fetch(this.api.off).then(() => {
this.headline.css("color", "#FFF")
})
}
}