html
html
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>💥Sound plays on click💥</title>
</head>
<body>
<h2>Click to play sound effect</h2>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
body {
background-color: black;
color: white;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
let boomAudio = new Audio("https://dl.dropbox.com/s/ywsabqq6209qsrg/Vine%20Boom%20Sound%20Effect%20%28Longer%20Verison%20For%20Real%29%20%28Read%20Description%20Please%29.mp3?dl=0");
boomAudio.preload="auto";
function playSound(audioObj, currentTime){
let audio = audioObj.cloneNode();
audio.currentTime = currentTime;
audio.play();
}
window.addEventListener('click', (e)=>{
playSound(boomAudio, 0.3);
});
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run