我正在创建一个包含javascript的表,我想要的一些行rowspan
,但它不起作用。例如,如果一行的行数为4,那么它在Mozzila Firefox中最多只显示2个行。但它谷歌Chrome它根本不起作用。
if (currentLectures.length === 1) { //If there is only one element in the array.
start = currentLectures[0].start;
end = currentLectures[0].end;
alert(end);
rowspan = end - start; //Rowspan if the lecture times are more than one hour.
column = document.createElement("td"); //Creating a <td> element.
column.setAttribute("class", "lectures");
column.setAttribute("rowspan", rowspan);
lecture = document.createTextNode(currentLectures[0].name);
column.appendChild(lecture);
tableRow.appendChild(column); //Adding the <td> element to the current row.
}
这是我得到的html输出:
<tbody>
<tr>
<th></th>
<td></td>
<td></td>
<td class="lectures"></td>
<td></td>
<td></td>
</tr>
</tbody>
<tbody>
<tr>
<th>
12:00
</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
我不确定为什么rowspan在这里不起作用。有任何想法吗?
答案 0 :(得分:0)
var column = document.createElement("td"); //Creating a <td> element.
column.innerHTML = '3';
column.rowSpan = 2
document.getElementById("tr_demo").appendChild(column);
试试吗?