// Toggle audio
var togglePlay = function(audioId)
{
var audio = document.getElementById(audioId);
if (audio.paused === false)
{
audio.currentTime = 0;
}
else
{
audio.play();
}
};
// Find all buttons
var buttons = document.getElementsByTagName('button');
// Set click event on all buttons
for(var i = 0; i < buttons.length; i++)
{
buttons[i].onmousedown = function()
{
togglePlay(this.getAttribute('data-audio-id'));
};
}