2014-12-03 190 views
0

我在頁面上創建了無限數量的div,我需要它們逐個顯示。也許每秒鐘都在消失,滾動到這個div。無論我做什麼,所有div都同時顯示。我不能管理滾動到在div衰落。謝謝一個循環中的淡入淡出同時淡入淡出

// Using multiple unit types within one animation. 
 

 

 

 
     $(document).ready(function() { 
 

 
    var divs = $('div[id^="gm"]'); 
 

 
    //alert(divs.length); 
 
    for(var i = 0; i < divs.length; i++){ 
 
    var thisDiv = divs[i]; // element 
 

 
    var $thisDiv = $(divs[i]); // jquery object 
 

 

 
      //animate($thisDiv); 
 
     //show($thisDiv, divs.length * 300); 
 
     //$thisDiv.delay(600) 
 
     setTimeout(
 
     $($thisDiv).slideUp(3000).delay(800).fadeIn(4000), 300); 
 

 
     } 
 

 
    
 
\t \t })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="row"> 
 

 
     <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> 
 
      <div class="panel panel-warning"> 
 
       <div class="panel-heading">Fight Stats</div> 
 
      </div> 
 

 
      
 
      <div class="panel panel-info"> 
 
       <div class="panel-heading"><span class="glyphicon glyphicon-flash "></span>ROUND 1</div> 
 
      </div> 
 

 
      <div class="panel-body"> 
 
       <div style="display: none" id="gmround1"> 
 

 
        <div style="display: none" id="gmplayer1round1"> 
 
         Player 1 casts a fireball... <span class="fa fa-magic"></span><br> 
 

 
         
 
         hits Player 2 with <span class="text-danger">40 </span> damage! 
 
         
 
         <em>(with a roll of 73)</em> 
 
         <br> 
 
         
 
        </div> 
 

 
        <div style="display: none" id="gmplayer2round1"> 
 

 

 
         
 
         Player 2 swings his hammer...<span class="fa fa-gavel"></span><br> 
 
         
 
         <strong>MISSES! </strong> 
 
         
 
         <em>(with a roll of 16)</em> 
 
         <br> 
 

 
         
 
         
 
        </div> 
 
       </div> 
 

 
      <div class="panel panel-warning" style="display: none" id="gmstatus1"> 
 
       <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> 
 
       <strong><i class="text-primary">Player 1</i></strong> 
 
        <div class="progress"> 
 
         <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="750" aria-valuemin="0" aria-valuemax="750" style="width:100%;"> 
 
         <span>750/750</span> 
 
         </div> 
 
        </div> 
 
       </div> 
 

 
       <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 text-right"> 
 
       <strong><i class="text-warning ">Player 2</i></strong> 
 
        <div class="progress"> 
 

 
         <div class="progress-bar progress-bar-warning progress-bar-striped active pull-right" role="progressbar" aria-valuenow="710" aria-valuemin="0" aria-valuemax="750" style="width:94.6666666667%;"> 
 
         <span>710/750</span> 
 
         </div> 
 
        </div> 
 
       </div> 
 

 
      </div> 
 

 
      </div> 
 

 

 

 
     
 
      <div class="panel panel-info"> 
 
       <div class="panel-heading"><span class="glyphicon glyphicon-flash "></span>ROUND 2</div> 
 
      </div> 
 

 
      <div class="panel-body"> 
 
       <div style="display: none" id="gmround2"> 
 

 
        <div style="display: none" id="gmplayer1round2"> 
 
         Player 1 casts a fireball... <span class="fa fa-magic"></span><br> 
 

 
         
 
         <strong>MISSES!</strong> 
 
         
 
         <em>(with a roll of 66)</em> 
 
         <br> 
 
         
 
        </div> 
 

 
        <div style="display: none" id="gmplayer2round2"> 
 

 

 
         
 
         Player 2 swings his hammer...<span class="fa fa-gavel"></span><br> 
 
         
 
         <strong>MISSES! </strong> 
 
         
 
         <em>(with a roll of 3)</em> 
 
         <br> 
 

 
         
 
         
 
        </div> 
 
       </div> 
 

 
      <div class="panel panel-warning" style="display: none" id="gmstatus2"> 
 
       <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6"> 
 
       <strong><i class="text-primary">Player 1</i></strong> 
 
        <div class="progress"> 
 
         <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="750" aria-valuemin="0" aria-valuemax="750" style="width:100%;"> 
 
         <span>750/750</span> 
 
         </div> 
 
        </div> 
 
       </div> 
 

 
       <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 text-right"> 
 
       <strong><i class="text-warning ">Player 2</i></strong> 
 
        <div class="progress"> 
 

 
         <div class="progress-bar progress-bar-warning progress-bar-striped active pull-right" role="progressbar" aria-valuenow="710" aria-valuemin="0" aria-valuemax="750" style="width:94.6666666667%;"> 
 
         <span>710/750</span> 
 
         </div> 
 
        </div> 
 
       </div> 
 

 
      </div> 
 

 
      </div>

回答

0

組延遲的時候,我多少?

$($thisDiv).slideUp(3000).delay(i * 800).fadeIn(4000), 300); 
+0

關於如何滾動到衰落div的任何想法? – senbon 2014-12-03 11:06:14