我想制作一个字符串数组,然后采摘一个随机字符串,并将其放在类“报价”的div。以下是我目前的代码。从jQuery数组随机文本
$(document).ready(function() {
var quotes = new Array("foo", "bar", "baz", "chuck");
var randno = Math.floor (Math.random() * quotes.length);
$('.quote').add(quotes[randno]);
});
我在做什么不正确?
感谢
什么是填充randno变量 – mguymon 2012-04-01 00:31:23
对不起,忘了补充该行。刚添加它。 – 585connor 2012-04-01 00:33:05
它是一个JavaScript数组,而不是一个jQuery数组。最好使用''[...]'而不是'new Array(...)' – ThiefMaster 2012-04-01 08:01:30