I'm about to add a sound on my links on mouse over, then will stop on mouse out and when it hover again, the sound will start to beginning.
I'm about to put it on links but what I'm not sure about is on how to add a function on my links:
The first thing I did is I added an audio on each links using javascript.
$('<audio src="http://audiopath/kiss.ogg" id="mySound"></audio>').appendTo('a');
Then I've added a function that will play the audio on mouse over which I just get from the other post.
function PlaySound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.play();
};
function StopSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.pause();
thissound.currentTime = 0;
};
I've tried to add a function those links but I'm having error. I just read from the other posts that it can be insert using attr.
$('a').onmouseover(function(){
$(this).attr('PlaySound', ('mySound'));
});
$('a').onmouseout(function(){
$(this).attr('StopSound', ('mySound'));
});
I'm implementing an output like this:
<a onmouseover="PlaySound('mySound')" onmouseout="StopSound('mySound')" href="#">Hover Over Me To Play</a>
Please help guys.....