Created
April 26, 2018 05:25
-
-
Save anwerashif/1e2f58d9238384a5781f14d04cabaf52 to your computer and use it in GitHub Desktop.
Pull audio file and play onclick
This file contains hidden or 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
$(document).ready(function() { | |
var audioElement = document.createElement('audio'); | |
audioElement.setAttribute('src', 'https://rainastudio.com/wp-content/themes/rainastudio/sound/rainastudio.mp3'); | |
audioElement.autoPlay=false; | |
$('#soundPlay').click(function(e) { | |
audioElement.play(); | |
// Cancel the default action | |
e.preventDefault(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment