-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
26 lines (23 loc) · 828 Bytes
/
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
let c = document.querySelector(".c");
let csh = document.querySelector(".csh");
let d = document.querySelector(".d");
let dsh = document.querySelector(".dsh");
let e = document.querySelector(".e");
let f = document.querySelector(".f");
let fsh = document.querySelector(".fsh");
let g = document.querySelector(".g");
let gsh = document.querySelector(".gsh");
let a = document.querySelector(".a");
let ash = document.querySelector(".ash");
let b = document.querySelector(".b");
let keys = [c, csh, d, dsh, e, f, fsh, g, gsh, a, ash, b];
function getdata(e) {
let val = e.target.getAttribute("data-key");
let audio = document.querySelector(`audio[data-key="${val}"]`);
if (!audio) {
return;
}
audio.currentTime = 0;
audio.play();
}
keys.forEach(key => { key.addEventListener("click", getdata) });