How do I stop sound on mouseout when hovering over an image?

29 Views Asked by At
<head>
var Start = new Audio("MySound.mp3");
</head>


<body>
<div>
<img src="MyPicture.png" width="400" height="300" onmouseover="Start.play();" onmouseout="Start.pause;"></img>
</div>
</body>

When hovering over the image the sound plays correctly but when I mouseout the sound continues playing? Not too sure why that is.

1

There are 1 best solutions below

1
Nacho Fernandez On BEST ANSWER

Change from onmouseout="Start.pause;"> to onmouseout="Start.pause();">. You missed the parenthesis in the pause function