0
我正在用javascript创建一个表格,我想要的一些行是rowspan
,但它不起作用。例如,如果一行的行跨度为4,那么它在Mozzila Firefox中只显示最多2个行数。但它谷歌浏览器它根本不工作。HTML rowspan不能和Javascript一起工作
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>
我不知道为什么行跨度是不是在这里工作。有任何想法吗?
您是否已验证该'if'语句的内部是否正在执行? – JLRishe 2014-10-03 04:32:28
@ JLRishe是的,我可以看到桌子 – user3898380 2014-10-03 05:14:57