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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -