我正在尝试使用 jquery 为我的所有导航按钮创建一个随机音频效果,基本上这个想法是你将鼠标悬停在唯一的导航 div 上并播放来自数组的随机音频 mp3 文件
<!DOCTYPE html>
<html>
<head>
<title>AAARGH CARIBBEAN PIRATES</title>
<meta charset = "utf8">
<link rel = "stylesheet" href = "main.css">
<script src = "jq/jquery-1.10.2.js"></script>
</head>
<body>
<div class = "wrapper">
<div class = "navmain">
<div class = "navbox">
<p class = "navi"><a href = "arms.html">arms</a></p>
</div>
<div class = "navbox">
<p class = "navi"><a href = "map.html">map</a></p>
</div>
<div class = "navbox">
<p class = "navi"><a href = "ship.html">ship</a></p>
</div>
<div class = "navbox">
<p class = "navi"><a href = "facts.html">facts</a></p>
</div>
<div class = "navbox">
<p class = "navi"><a href = "speech.html">speech</a></p>
</div>
</div>
<div id = "home">
<div id = "innerhome">
<p class = "basic">
AAARGH mateys, the caribbean was a ..
</p>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('.navbox').onmouseover(playSound());
});
function playSound(){
var audio[];
audio[0] = new Audio("assetts/audio/bird.mp3");
audio[1] = new Audio("assetts/audio/cannon.mp3");
audio[2] = new Audio("assetts/audio/fire.mp3");
audio[3] = new Audio("assetts/audio/monkey.mp3");
audio[4] = new Audio("assetts/audio/crows.mp3");
audio[5] = new Audio("assetts/audio/cannon2.mp3");
var x = Math.floor((Math.random()*1000) % 6);
audio[x].play();
}
</script>
</body>
它不起作用..不确定我哪里出错了