我在javascript中使用2个数组填充单词,然后使用随机化显示每个数组中的1个单词。但是,如果我想在第一个数组中选择第二个单词时播放标记为“1.mp3”的特定声音,并在第二个数组中选择了第九个单词时播放标记为“8.mp3”的声音。这些声音会按照第一个数组声音的顺序播放,然后是第二个数组声音。我正在使用cordova的Media插件来支持电话。任何人都可以指引我走向正确的方向吗?根据随机数组结果播放特定的声音?
JavaScript的数组是这样的:
var wordlist1 = ["Aggressive", "Amazing", "Attractive", "Black", "Broken", "Brave",
"Caring", "Cold", "Corny", "Delicious", "Dramatic", "Dull", "Euphoric", "Exotic",
"Evil", "Fabulous", "Feminine", "Fat", "Glorious", "Gripping", "Grand", "Hairy",
"Horny", "Hard", "Immense", "Idiotic", "Inferior", "Jam-Packed", "Juicy", "Jealous",
"Kooky", "Klutzy", "Knowledgeable", "Lame", "Lazy", "Loving", "Mad", "Milky", "Moist",
"Naive", "Naughty", "Neglected", "Oily", "Obese", "Overcooked", "Passionate", "Party",
"Peaceful", "Pasty", "Questionable", "Queasy", "Qualified", "Reckless", "Repulsive",
"Rubbery", "Slimy", "Salty", "Stiff", "Thick", "Terrible", "Thunderous", "Ugly",
"Uncomfortable", "Unpleasant", "Violent", "Vivid", "Vicious", "Wobbly", "Wee", "Wet",
"Young", "Yummy", "Yellowish", "Zany", "Zappy", "Zealous"]
var displayword1 = wordlist1[Math.floor(Math.random() * wordlist1.length)];
document.getElementById("word1").innerHTML = displayword1
第二阵列是几乎相同的保存阵列&名 的内容,那么我有一个HTML文件,将加载脚本;
<p id="word1"></p>
<script src="main.js"></script>
请问您能否添加一些描述您迄今所做工作的代码? – Friederike 2014-10-02 13:50:48
我用一些代码编辑了原文。 – MrBalrog 2014-10-02 13:55:01