我使用以下代码播放随机音频文件(从1.wav命名为15.wav的文件)变量' file'正在显示随机文件。但是每次点击鼠标都会播放相同的文件
$(document).ready(function() {
$("body").click(function() {
function explode() {
var file = Math.floor(Math.random() * 14) + 1 + '.wav';
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', file);
audioElement.setAttribute('autoplay', 'autoplay');
//audioElement.load()
$.get();
audioElement.addEventListener("load", function() {
audioElement.play();
}, true);
}
setTimeout(explode, 5000);
});
});