I want playSound()
function to do its job according to the id
of the chosen (hovered) image.
Nothing I tried has worked even a bit, so I need full help on this one.
code:
var sound1 = document.getElementById("audio1");
var sound2 = document.getElementById("audio2");
function playSound() {
//if hovered image has id="x", do this
sound1.play();
//if hovered image has id="y", do this
sound2.play();
}
<a href="Okokoska.html"><img src="Pkokoska.jpg" id="x" onmouseover="playSound()" onmouseout="stop()"></a>
<a href="Okonj.html"><img src="Pkonj.jpg" id="y" onmouseover="playSound()" onmouseout="stop()"></a>
<audio id="audio1"><source src="Zkokoska.wav"></audio>
<audio id="audio2"><source src="Zkrava.wav"></audio>