var music=$("#music>a"); music.toggle(function(){ $(this).css("background","url(img/stop.png) 5px center no-repeat"); media.pause(); },function(){ $(this).css("background","url(img/play.gif) 5px center no-repeat"); media.play(); });
<div id="music"><a href="javascript:void(0)">MUSIC</a> <audio id="media" src="sounds/bg.mp3" autoplay="autoplay" loop="loop"></audio></div>