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=\'2\'>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)"));
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!