$(document).ready(function() {
var audioElement = document.createElement('audio');
$('#play').click(function() {
audioElement.play();
});
});
<script src="http://example.com/wp-content/playsounds.js"></script>
<button id="play" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
Button
</button>
I had a question about multiple sources for an audio element.
I read a good way to make buttons playable with javascript at Play an audio file using jQuery when a button is clicked
The problem is I need multiple different sources / play buttons on the same page, for many different pages.
One solution seems to have a separate .js file for each page or even each button, but I know there has to be a simple solution via html or css.
Basically, on my page I want to be able to have buttons with various different sounds, and just put a simple src or source tag and the address of the sound file for each.
I am also using Material Design lite for my buttons.
My current code on my site looks like this