如果数据相同,则使用html表跨度 [英] html table span if the data is same
问题描述
我在列中有一个包含重复数据的html表格,如下所示: 我想动态合并HTML表格行单元格,如果数据与下表相同 我可以通过给单元格的数量来实现这个功能,但是我怎样才能动态地执行这个操作? <哇,谢谢你的有趣的任务。我想出了这个解决方案 http://jsfiddle.net/PhWGF/4/ 。不是最干净的代码,但我会为你留下这部分。 你可以把你的表看作一个普通的
2d数组$ c $所以这一切都归结为经典的嵌套循环。我们为同一列的每一行中的每个单元格搜索一个副本,并存储第一个和最后一个出现以确定后续跨度的长度。
I have a html table with duplicate data in the column as shown below
I want to dynamically merge the html table row cell if the data is same like below table
I am able to do this with giving the value number of cells to span but how can I do this dynamically
Wow, thanks for the interesting task. I came up with this solution http://jsfiddle.net/PhWGF/4/. Not the cleanest code but I will leave this part for you.
You can think about your table as a regular 2d array
so it all comes down to the classical nested loops. We search for a duplicate for each cell in each row of the same column, store first and last occurrence to determine the length of span later.
Note, you need to set all "roswpan" before deleting duplicates.
这篇关于如果数据相同,则使用html表跨度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!