mouseout

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


<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.


Solution

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