【发布时间】:2014-10-03 04:03:51
【问题描述】:
我正在使用 javascript 创建一个表,其中一些行是我想要的 rowspan,但它不起作用。例如,如果一行的行跨度为 4,那么它在 Mozzila Firefox 中最多只显示 2 个行跨度。但它谷歌浏览器根本不起作用。
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 是的,我可以看到表格
标签: javascript html