views:

928

answers:

1

I have the following HTML

<table id="tbl1">
  <!-- Table row trHeader should be here based on a flag //-->  
</table>
<table id="tbl2">
  <tr id="trHeader">
     <td>test</td>
  </tr>
</table>

I have a flag (essentially a button), that I use to be able to move the table row with id="tbl2". How would I switch it back to the same position based on this flag.

+2  A: 

Try something like this

$('#tbl1').append($('#trHeader').remove());

Update, I'm not sure where your button is to do the toggling, I'm going to assume that your toggling when you click the header row. If otherwise, let me know.

$('#trHeader').toggle(function() {
  $('#tbl1').append($(this).remove());
}, function() {
  $('#tbl2').append($(this).remove());
});
bendewey
I would like to toggle between appending and removing. How would I do that?
DotnetDude
I updated my post. Where's your button to do the toggling?
bendewey