Home > Web Front-end > JS Tutorial > body text

jquery dynamically merge cells

php中世界最好的语言
Release: 2018-03-15 13:34:18
Original
2227 people have browsed it

This time I will bring you jquery dynamically merging cells, what are the precautions for jquery dynamically merging cells, the following is a practical case, let’s take a look.

is as follows:

////在table的第二行的位置添加一行:
var tbl_elm = $("#dgList");
$('<tr><td colspan=\&#39;2\&#39;>xxxxxx</td></tr>').insertBefore($("TR", tbl_elm).eq(1))
////table中指定行第N列合并单元格(合并后会多出一列,删除N+1单元格即可)
var tds = $("#dgList .TableHeader1").find('td');
tds[6].setAttribute("colSpan", "2");
还可以写成:tds[6].attr("rowSpan", 2);
这种格式$("#dgList").find("tr").eq(0).find("td").eq(7).remove();
////juqery 读取table第N行第M列
 $("#dgList").find("tr").eq(N).find("td").eq(M);
 
////合并一行中除个别单元格之外的所有单元格
  $("#dgList tr:eq(0) td").each(function () {
  if ($(this).text() != '租赁资源' && $(this).text() != '用地规范') {
    $(this).attr("rowspan", "2");
  }
});
 ////指定行插入指定行后面
$('<tr><td>租赁资源</td><td>用地规范</td></tr>').insertAfter($("#dgList tr:eq(0)"));
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related matters on the php Chinese website article!

Recommended reading:

C3+jQuery to create animation effects and callback functions

How to implement dynamic data paging with jQuery+ajax

How to extract data assignment with ajax in jQuery

The above is the detailed content of jquery dynamically merge cells. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template