<!DOCTYPE html>
<html>
<body>
<img id="myImage" onclick="aud_play_pause()" src="../../images/off.png" alt=""/>
<audio id="myAudio">
</audio>
<script>
function aud_play_pause()
{
var song = ["../Sesler/3.mp3"];
var myAudio = document.getElementById("myAudio");
var image = document.getElementById('myImage');
myAudio.src = song;
if (myAudio.paused)
{
image.src = "../../images/on.png";
myAudio.play();
}
else if(image.src.match("on"))
{
image.src = "../../images/off.png";
myAudio.pause();
}
}
</script>
</body>
</html>
Hi,
I couldn't understand why it doesn't work. It is suppose to start when I click (it starts) and it is suppose to pouse when I click again (it doesn't). I think the "else if" statement doesn't work but why?
Thanks,
H. Caglar
Aucun commentaire:
Enregistrer un commentaire