I am learning HTML-CSS-JS by doing some little exercises of my own. I have created a little code that plays an mp3 audio when I click on an image:
<html>
<head>
<title>Image audio exercise</title>
</head>
<body>
<script>
function play(){
var audio = document.getElementById("audio");
audio.play();
}
</script>
<img src="img.gif" onclick="play()">
<audio id="audio" src="sound.mp3" ></audio>
</body>
</html>
I would like to be able to play a different audio file when the click is outside the image. Is there a simple way to do it? Maybe an if-else statement?