javascript - Toggle through tables -


i have jquery displays 4 tables simultaneously, how display 1 table @ time toggle though button?

i have displayed part of code below. great thanks.

    <script type="text/javascript">      function call_everybody(){                                          display_cyclist_results_table();         display_cyclist2_results_table();         display_cyclist3_results_table();         display_cyclist4_results_table();         cyclist_heading();     }  </script>      <table class="resultstable" align="center">              <tr><td class="tdcells"><div id="cyclist_table"></div></td>                 <td class="tdcells"><div id="cyclist2_table"></div></td>                 <td class="tdcells"><div id="cyclist3_table"></div></td>                 <td class="tdcells"><div id="cyclist4_table"></div></td></tr>     </table> 

assuming have same class, should work

var $tables = $('.resultstable');//cache table elements avoid repeated dom searches $tables.not(':first').hide();  $('#somebutton').click(function(){     var $currtable = $tables.filter(':visible').hide(),         nextindex = $tables.index($currtable) +1;                if(nextindex === $tables.length){          nextindex = 0;     }      $tables.eq(nextindex).show();    }); 

Comments

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

java - Incorrect order of records in M-M relationship in hibernate -