1
我有一個單元格具有相同值的表格。我正嘗試使用colspan將它們合併在一起,但爲colspan設置屬性不起作用。Colspan屬性沒有從變量設置
https://jsfiddle.net/afn4f1q9/4/
$(function() {
$('table.merge tr').each(function() {
var tr = this;
var counter = 1;
var prevValue = false;
var colspanTD = false;
$('td', tr).each(function(index, value) {
var td = $(this);
if (counter == 1) {
colspanTD = $(this);
}
if (prevValue !== false) {
if (td.text() == prevValue) {
if (td.text() != '' && td.text() != 'X' && td.text() != '*') {
counter++;
td.remove();
}
} else {
$(colspanTD).attr('colspan', counter);
counter = 1;
}
}
prevValue = td.text();
});
});
});