总而言之,我正在尝试使用随机报价生成器.我的代码非常简单......
var myQuotes = [
{
quote: "To err is human; to forgive, divine.",
cite: "Alexander Pope"},
{
quote: "Reports of my death have been greatly exaggerated.",
cite: "Mark Twain"}
];
var randomQuote = Math.floor(Math.random() * myQuotes.length);
$('.quote').html(myQuotes[randomQuote].quote); // #1
$('.cite').html(myQuotes[randomQuote].cite);
setInterval(function() {
$('.quote').fadeOut();
$('.quote').fadeIn().html(myQuotes[randomQuote].quote); // #2
}, 3000);
Run Code Online (Sandbox Code Playgroud)
在加载时,它显示#1就好了,但#2似乎不起作用......它只是保持闪烁与之前相同的一个,#1中的那个.我对此不了解什么?