JSFiddle - React, Tailwind, and code Playground
HTML
<audio id="player" src="http://www.soundjay.com/ambient/check-point-1.mp3"></audio>
<a class="soundIcnPlay" title="button" id="button"> </a>
CSS
.soundIcnPlay {
background: none repeat scroll 0 0 red;
cursor: pointer;
display: block;
height: 100px;
width: 100px;
}
.soundIcnPause {
background: none repeat scroll 0 0 blue;
cursor: pointer;
display: block;
height: 100px;
width: 100px;
}
JavaScript
$(document).ready(function() {
var playing = false;
$('a#button').click(function() {
$(this).toggleClass("down");
if (playing == false) {
document.getElementById('player').play();
playing = true;
$(this).removeClass('soundIcnPlay');
$(this).addClass('soundIcnPause');
} else {
document.getElementById('player').pause();
playing = false;
$(this).removeClass('soundIcnPause');
$(this).addClass('soundIcnPlay');
}
});
});