更新时间:2022-12-12 15:16:47
$('table tr:nth-child(3)').after('<div>....</div>');
每次都会在第三行之后插入内容!
This will insert something after the 3rd row every time!
$('table .one:nth-child(3)').after('<div>....</div>');
这将在第3个.one
类之后插入一些内容.
This will insert something after the 3rd .one
class.
$('table .two:nth-child(1)').before('<div>....</div>');
这将插入第一个.two
类之前.意味着它将在.one
&之间. .two
.
This would insert before the first .two
class. Meaning it would be inbetween .one
& .two
.
据我对您的评论的了解,您想在最后一个.one
tr
之后插入一个元素.
From what I understand of your comment, you would like to insert an element after the last .one
tr
.
可以使用以下方法轻松完成此操作:
This can easily be done by using this:
$('.one').last().after('<div>...code goes in here...</div>');
OR
$('.one:last-child').after('<div>...</div>');