我有一张这样的表
<table>
<tr>
<td colspan="3" class="details">Some Text</td>
</tr>
<tr>
<td>Some Text</td>
<td>Some Text</td>
<td>Some Text</td>
</tr>
</table>
我怎样才能将colspan修复为普通表列,以便将列平均分配..?感谢
答案 0 :(得分:0)
这是第一种想到的方式:
$("td[colspan]").each(function() { // find all tds that have a colspan specified
var $td = $(this),
cols = +$td.attr("colspan"); // get the value
$td.attr("colspan",1); // set the cell to have colspan 1
for (var i = 1; i < cols; i++) // add as many clones of the current cell
$td.after($td.clone()); // as needed to replace the original colspan
});