I have the following HTML
我有以下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.
我有一个标志(实际上是一个按钮),我用它来移动id =“tbl2”的表行。如何根据此标志将其切换回相同的位置。
1 个解决方案
#1
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());
});
#1
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());
});