Skip to content

Instantly share code, notes, and snippets.

@geta6
Created September 22, 2013 09:43
Show Gist options
  • Save geta6/6658445 to your computer and use it in GitHub Desktop.
Save geta6/6658445 to your computer and use it in GitHub Desktop.
<html>
<body onload='init()'>
<button id='b'>BEEEER</button>
<button id='c'>CABBBB</button>
<button id='e'>EGGGGG</button>
<script>
init = function () {
var b = new Audio('./beer.mp3');
var c = new Audio('./cabbage.mp3');
var e = new Audio('./egg.mp3');
var be = document.getElementById('b');
var ce = document.getElementById('c');
var ee = document.getElementById('e');
console.log(be);
be.addEventListener('click',function(){
b.pause();
b.currentTime = 0;
b.play();
});
ce.addEventListener('click', function(){
c.pause();
c.currentTime = 0;
c.play();
});
ee.addEventListener('click',function(){
e.pause();
e.currentTime = 0;
e.play();
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment