开发者

jQuery append() only certain columns

I have two tables on my page. The first one has three columns and the second one has two. The middle column on the first table is an image that when you click on it, it will move that row down to the second table. At the moment I have

$('table td img.add').live('click', (function() {
  $('table#tblName').append( $(this).closest('tr') );
}));

Which works. The row is removed from the first table and put at the bottom of the second. The only problem is that I want to only move the 1st and 3rd columns. I tried adding a middle column in the second table and then using jQuery to hide it when the page loaded, but as soon as I appended a row, that new row has th开发者_高级运维ree cells.


this should work.

$('table td img.add').live('click', (function() {
  var parent = $(this).closest('tr');
  // remove the middle td
  $(this).closest('td').remove();
  $('table#tblName').append( parent );
}));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜