Jquery 如何添加淡入淡出功能来播放悬停功能?

Jquery 如何添加淡入淡出功能来播放悬停功能?,jquery,audio,fadein,fadeout,Jquery,Audio,Fadein,Fadeout,我有下面的代码,可以在悬停在一个对象上时激活声音,但我想添加简单的淡入淡出效果(悬停时淡入淡出)。我很乐意得到提示 function PlaySound(soundobj) { var thissound=document.getElementById(soundobj); thissound.play()} function StopSound(soundobj) { var thissound=document.getElementById(soundobj); thissound.pau

我有下面的代码,可以在悬停在一个对象上时激活声音,但我想添加简单的淡入淡出效果(悬停时淡入淡出)。我很乐意得到提示

function PlaySound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.play()}

function StopSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.pause();
thissound.currentTime = 0;}
谢谢你

它似乎仍然不起作用。我纠正了一些事情,并尝试了以下方法:

 function PlaySound(soundobj) {
var thissound=document.getElementById(soundobj);

/* putting sound on hold and setting volume to 0 */
thissound.pause().prop("volume", 0);

/* on mouse hover event, play sound and fade in the volume in 1s */
thissound.mouseover(function() {
    thissound.play().animate({volume: 1}, 1000);
});}

function StopSound(soundobj) {
var thissound=document.getElementById(soundobj);

/* on mouse out event, fade out the volume in 1s */
thissound.mouseout(function() {
    thissound.animate({volume: 0}, 1000)}
});
thissound.pause();
thissound.currentTime = 0;
}
我的问题是, 初始音量设置是否应与播放声音功能分开? mouseout函数中的行是否应为:
thissound.play().animate({volume:0},1000)}

谢谢