javascript - Show multi-elements asynchronous -


i have multi div like

<div class="a">a1</div> <div class="a">a2</div> .....  .a{display: none} 

i try show of them way:
show direct div when complete 1 one when show(it mean show 1 after other complete)

i try not working. how thank

function test(child) {     settimeout(function(child) {         child.show();         // mean don't know when div finish show, defend caculate         (var = 0; < 5000000*random_number; i++) {             var x = 0;         }     }, 0); } $(".a").each(function( index ) {     test($(thís)); }); 

try this, inside jquery callback function check next sibling

$(function() {      var showtime = 1000;      $($('.a')[0]).show(showtime, shownextdiv.bind(null, $($('.a')[0])))      function shownextdiv($elem) {        var el = $elem.next('.a')[0];        $(el).show(showtime, shownextdiv.bind(null, $(el)))      }    })
.a {    background-color: red;    border: 1px solid;    margin: 2px;    display: none;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div class='a'>test</div>  <div class='a'>test</div>  <div class='a'>test</div>  <div class='a'>test</div>  <div class='a'>test</div>


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -