tags:

views:

28

answers:

1

I would like to toggle my table row on an .change function in jquery. The desired row is being displayed in this code, how do I hide the other rows at the same time?

$(document).ready(function() {
   $('#ddlSelect').change(function() {
      var ddlId = $('#ddlSelect').val();
      alert(ddlId);         
      //$('#displayTable').hide();
      $('#' + ddlId).show();
   });
});
A: 

Does this work?

$(document).ready(function() {
   $('#ddlSelect').change(function() {
      var ddlId = $('#ddlSelect').val();
      $('#displayTable tr').each( function() {
          $(this).hide();
      });
      $('#' + ddlId).show();
   });
});
Chris Conway
I think this is hiding the entire table so the row is not being displayed...
I got it... $('#displayTable tr').each( function() { toggles through each row. Could you make the edit so I can credit you for the answer. Thanks!
that looks better. thanks!
Chris Conway