使用jQuery mouseenter播放单个wav文件
我正在对象中存储一些jQuery代码,需要使用使用jQuery mouseenter播放单个wav文件,jquery,function,loops,Jquery,Function,Loops,我正在对象中存储一些jQuery代码,需要使用.mouseenter播放特定的本地音频文件。我在本地存储了16个不同的文件,每个文件的名称与按钮id相同。例如,声音文件“work_it.wav”将为work it播放。没有必要停止音频,因为每个文件只有2-3秒长 我想在我的“播放声音”函数中循环。我的代码在下面,任何帮助都是感激的 var daftP = daftP || {}; daftP.setup = function() { this.$audio = $('#sounds');
.mouseenter
播放特定的本地音频文件。我在本地存储了16个不同的文件,每个文件的名称与按钮id相同。例如,声音文件“work_it.wav”将为work it
播放。没有必要停止音频,因为每个文件只有2-3秒长
我想在我的“播放声音”函数中循环。我的代码在下面,任何帮助都是感激的
var daftP = daftP || {};
daftP.setup = function() {
this.$audio = $('#sounds');
this.$audio = $('audio');
this.$heads = $('.buttons');
this.colorChange();
};
daftP.colorChange = function() {
this.$heads.each(function() {
$(this).on('mouseenter', function() {
$(this).css('background-image', 'url(images/helmet2.png)');
this.playSound();
});
$(this).on('mouseout', function() {
$(this).css('background-image', 'url(images/helmet1.png)');
});
});
};
daftP.playSound = function() {
};
$(daftP.setup.bind(daftP));