淡入淡出文本循环 – jQuery

我有两个引号包含在H2标签中,我想使用jQuery进出.当页面加载时,我希望第一个报价淡入,延迟几秒钟,然后淡出,然后下一个报价来做同样的报价.我希望继续循环使用这两个引号.任何帮助将不胜感激.

解决方法

你可以这样做:

CSS:

.quotes {display: none;}​

HTML:

<h2 class="quotes">first quote</h2>
<h2 class="quotes">second quote</h2>​

使用Javascript:

// code gets installed at the end of the body (after all other HTML)
(function() {

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

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

    showNextQuote();

})();​

工作演示:http://jsfiddle.net/jfriend00/n4mKw/

代码将适用于您拥有的任何数量的引号,而不仅仅是两个.如果您在引号后面有内容,您可能需要修正引号所在容器的大小,以便在从一个引用到下一个引用(导致其他页面内容跳转)时不会更改大小,.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...