html + js淡出淡出文本注释

时间:2013-03-06 13:28:49

标签: jquery html comments fade

我有这个代码,它运行得很好,唯一的问题是在最后一个引用被使用之后,它将在从开头再次开始之前显示一个空div几秒钟。所以,我的问题是如何在使用最后一个之后跳回到第一个引用。谢谢。 (您可以在mapsbyphil dot com中查看它。)

<div id="container">
<div>
 <p><b>"The early days of GIS were very lonely. No-one knew what it meant."</b><br><a href="http://en.wikipedia.org/wiki/Roger_Tomlinson"  target="_blank">Roger Tomlinson</a>, Father of GIS</p>
</div>
<div>
 <p><b>“GIS is a form of digital mapping technology.  Kind of like Google Earth, but better.”</b><br><a href="http://en.wikipedia.org/wiki/Arnold_Schwarzenegger"  target="_blank">Arnold Schwarzenegger</a>, Conference on California's Future 2008</p>
</div>
<div>
 <p><b>“I am told there are people who do not care for maps, and I find it hard to believe.”</b><br><a href="http://en.wikipedia.org/wiki/Robert_Louis_Stevenson"  target="_blank">Robert Louis Stevenson</a></p>
</div>
<div>
 <p><b>“Everything is related to everything else, but near things are more related than distant things.”</b><br><a href="http://en.wikipedia.org/wiki/Tobler%27s_first_law_of_geography"  target="_blank">Tobler's First Law of Geography</a></p>
</div>
<div>
 <p><b>"It is not down in any map; true places never are."</b><br><a href="http://en.wikipedia.org/wiki/Herman_melville"  target="_blank">Herman Melville</a></p>
</div>
<div>
 <p><b>"They were maps that lived, maps that one could study, frown over, and add to; maps, in short, that really meant something.” </b><br><a href="http://en.wikipedia.org/wiki/Gerald_Durrell"  target="_blank">Gerald Durrell</a></p>
</div>
<div>
 <p><b>“I get to go to overseas places, like Canada.” </b><br><a href="http://en.wikipedia.org/wiki/Britney_Spears"  target="_blank">Britney Spears</a></p>
</div>
<div>
 <p><b>“I like geography. I like to know where places are.” </b><br><a href="http://en.wikipedia.org/wiki/Tom_Felton"  target="_blank">Tom Felton</a></p>
</div>
<div>
 <p><b>"I have no idea where Italy is on the map, but I do know what shape it is, and its like a boot." </b><br><a href="http://en.wikipedia.org/wiki/Snooki"  target="_blank">Snooki</a></p>
</div>
<script type="text/javascript">
function InOut(elem)
{
elem.delay()
 .fadeIn(600)
 .delay(5000)
 .fadeOut(600,
     function(){
        if(elem.next().length > 0) 
          { InOut(elem.next()); }
        else
          { InOut(elem.siblings(':first')); }

      }
    );
}

$('#container div').hide();
InOut($('#container div:first'));
</script>

1 个答案:

答案 0 :(得分:0)

我认为你实际上是在尝试展示<script>,因为它是最后一个兄弟姐妹。您可能希望将<script>放在<div id="container">之外。

或者您可以将选择器'div'传递给next() function