我正在尝试创建一个字符串数组,然后选择一个随机字符串并将其放在带有"引用"类的div中.以下是我目前的代码.
$(document).ready(function() {
var quotes = new Array("foo", "bar", "baz", "chuck");
var randno = Math.floor ( Math.random() * quotes.length );
$('.quote').add(quotes[randno]);
});
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
谢谢
小智 11
$(document).ready(function() {
var quotes = new Array("foo", "bar", "baz", "chuck"),
randno = quotes[Math.floor( Math.random() * quotes.length )];
$('.quote').text( randno );
});
Run Code Online (Sandbox Code Playgroud)
试试这个
归档时间: |
|
查看次数: |
10146 次 |
最近记录: |