克隆表行而不是第一个td-jQuery [英] Clone table row but not first td - jQuery

查看:76
本文介绍了克隆表行而不是第一个td-jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery中的clone函数时遇到一些问题.我已经能够克隆表头(第一行).但是我还需要从行(th)中删除第一个元素,我已经尝试了很多事情,但是一直失败,这是我的尝试之一:

I am having some problem using the clone function in 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 ?

推荐答案

如果要克隆整个tr,则它将包括其所有子代.您可以克隆元素,然后remove()令人反感的元素.

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();

这篇关于克隆表行而不是第一个td-jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆