开发者

Clone table row but not first td - jQuery

开发者 https://www.devze.com 2023-01-25 08:01 出处:网络
I am having some problem using the clone function in 开发者_JS百科jQuery. I have been able to clone the table header (first row). But I also need to remove the first element from the row (th), I have

I am having some problem using the clone function in 开发者_JS百科jQuery. I have been able to clone the table header (first row). But I also need to remove the first element from the row (th), I have tried quite a few things but keep failing, here is one of my attempts:

$('.teamStatusTable tr:first:not("th:first-child")').clone().prependTo($('#tableTrackActual'));

Does anyone know a method that works ?


If you're cloning the entire tr, then it'll include all of its children. You can clone the element and then remove() the offending element element.

$('.teamStatusTable tr:first').clone().prependTo(...).find('th:first-child').remove();
0

精彩评论

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