Created
May 15, 2015 01:05
-
-
Save code-for-coffee/8497ea51a0ee8fd9f2e4 to your computer and use it in GitHub Desktop.
Play audio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<audio id="kablam!"> | |
<source src="/assets/kablam.mp3" type="audio/mpeg"> | |
</audio> | |
<button id="playSoundBtn">Kablam!</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// selector: `button` with an id attribute of `playSoundBtn` | |
$('#playSoundBtn').on('click', function(event) { | |
// get the audio element by Id and play() it | |
document.getElementById('kablam!').play(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment