我想创建一个与之前动态创建的宽度相同的表格(表格及其单元格)
第一
__________________
|_____|___|_______|
|_____|___|_______|
|_____|___|_______|
第二
__________________
|_____|___|_______|
|_____|___|_______|
我需要做什么才能将第二个设置为所需的宽度。 (表 1 的宽度取决于它的内容)。
编辑: 最后,我选择了 jQuery 解决方案并这样做了:
$("#mySecondTable tr") // mySecondTable was already generated server side
.first() // All rows in my second table are similar so I just apply on the first one
.find("td")
.width(function(i){ return $("#myFirstTable tr").eq(1).find("td").eq(i).width() })
// eq(1) fetches the line I want to use as a model since some have different colspans
.end()
最佳答案
使用 Javascript(我推荐 jQuery)从第一个表中获取每个“列”的宽度(th
/td
),并设置 width
CSS 属性设置为第二个表中第 th
和/或 td
的像素值。
关于php - 如何创建与前一个表格具有相同尺寸的表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2364690/