如何在两个表格行之间插入另一个表格行? [英] How to insert another table row between two table rows?

查看:30
本文介绍了如何在两个表格行之间插入另一个表格行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<table>
 <tr>
  <td>Row 1 Column1</td>
  <td>Row 1 Column2</td>
 </tr>
 <tr class="dynamicRows">
  <td>Row 2 Column1</td>
  <td>Row 2 Column2</td>
 </tr>
 <tr class="dynamicRows">
  <td>Row 3 Column1</td>
  <td>Row 3 Column2</td>
 </tr>
 <tr>
  <td>Row 5 Column1</td>
  <td>Row 5 Column2</td>
 </tr>
</table>

这是表结构.我想在行下方插入

This is the Table Structure. I want to insert below Row

<tr class="dynamicRows">
 <td>Row 4 Column1</td>
 <td>Row 4 Column2</td>
</tr>

在第三行之后,我想在 "dynamicRows" 类的末尾通过 Jquery 插入新的行元素.请帮我解决这个问题.

After the 3rd row I want to insert new row elements via Jquery at the end of "dynamicRows" class. Please help me sort out this issue.

此代码运行良好.

$('table tr.categories:last').after(returnData);

推荐答案

var block = '<tr class="dynamicRows">'+
                '<td>Row 4 Column1</td>'+
                '<td>Row 4 Column2</td>'+
            '</tr>';


$('.dynamicRows').last().after(block);

这篇关于如何在两个表格行之间插入另一个表格行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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