Last active
October 28, 2015 20:45
-
-
Save aamnah/0c15a3558cfe4b929f45 to your computer and use it in GitHub Desktop.
play audio when clicked
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
<!-- image --> | |
<a href="javascript:play('dog')"><img src="img/dog.png"></img></a> | |
<!-- link --> | |
<a href="javascript:play('dog')">Dog</a> | |
<!-- audio file --> | |
<audio | |
id="dog" | |
src="media/dog.wav" | |
preload="auto" | |
></audio> | |
<!-- JS --> | |
<script type="text/javascript"> | |
function play(media) { | |
document.getElementById(media).play(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment