0



仅供参考,这已解决。www.WEBCO-MN.com - 滚动到底部显示“客户在说什么......”谢谢您的帮助!

我对这一切都很陌生。我知道 HTML - 不是专业人士。
我真的不知道javascript。我习惯了只是复制和粘贴它。我正在尝试创建一个推荐部分,因此它会从一个推荐淡入另一个推荐,等等。一旦我使用了在这里找到的代码:
淡入淡出文本循环 - jQuery,什么都没有出现。

这是我正在处理的页面的链接:
http ://www.webco-mn.com/webco_test3.html

这是我正在做的事情:
HTML:

    <h2 class="quotes">first testimonial</h2>
    <h2 class="quotes">second testimonial</h2>

JS:

    (function() {

var quotes = $(".quotes");
var quoteIndex = -1;

function showNextQuote() {
    ++quoteIndex;
    quotes.eq(quoteIndex % quotes.length)
        .fadeIn(2000)
        .delay(2000)
        .fadeOut(2000, showNextQuote);
}

showNextQuote();

    })();

和 CSS:

    .quotes {display: none;}​

有人可以帮我弄清楚发生了什么吗?!

PS - 我没有设计这个网站,我也没有接触过任何设计的 HTML 部分,我不是那么先进,我不想破坏任何东西。

4

1 回答 1

0

为了使用该 jQuery 代码,您需要链接到 jQuery javascript 库。

在您链接到的测试页面中,您在结束 html 标记后引用了要使用的脚本和 jQuery:

</html>
<script>
(function() {

    var quotes = $(".quotes");
    var quoteIndex = -1;

    function showNextQuote() {
        ++quoteIndex;
        quotes.eq(quoteIndex % quotes.length)
            .fadeIn(2000)
            .delay(2000)
            .fadeOut(2000, showNextQuote);
    }

    showNextQuote();

})();</script>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>

尝试在元素末尾添加对 jQuery 的引用<head>,并在元素末尾添加您尝试使用的脚本<body>

我还建议阅读有关 jQuery 工作原理的基本概述

于 2013-03-12T19:37:35.783 回答