expand only one table row using jquery -


i'm using jquery expand row in table when row clicked. how modify code when row clicked, open row collapses?

here table:

<table class="tb">  <tbody>   <tr class="parent"><td>click here</td></tr>   <tr><td>hidden row</td></tr>   <tr class="parent"><td>or click here</td></tr>   <tr><td>another hidden row</td></tr>  </tbody>     </table> 

and here jquery:

$('table.tb').each(function() {  var $table = $(this);  $table.find('.parent').click(function() {   $(this).nextuntil('.parent').toggle();  });  var $childrows = $table.find('tbody tr').not('.parent').hide(); }); 

change function hide each parent on click

http://jsfiddle.net/ugwfq/1/

$(".parent").children("td").click(function() {     $(".parent").next("tr").hide();     $(this).parent().next("tr").show(); }); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

php - Dynamic url re-writing using htaccess -

java - Multi-Label Document Classification -