HTML行span不使用Javascript
我正在用javascript创建一个表,其中一些行是我想要的HTML行span不使用Javascript,javascript,html,Javascript,Html,我正在用javascript创建一个表,其中一些行是我想要的rowspan,但它不起作用。例如,如果一行的行跨度为4,那么它在Mozzila Firefox中最多只显示2个行跨度。但它根本不起作用 if (currentLectures.length === 1) { //If there is only one element in the array. start = currentLectures[0].start; end = curren
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.
}
if(current.length==1){//如果数组中只有一个元素。
开始=当前课程[0]。开始;
结束=当前课程[0]。结束;
警报(结束);
rowspan=end-start;//如果讲座时间超过一小时,则为rowspan。
column=document.createElement(“td”);//创建元素。
column.setAttribute(“类”、“讲座”);
column.setAttribute(“rowspan”,rowspan);
讲座=document.createTextNode(当前讲座[0].name);
专栏.儿童(讲座);
tableRow.appendChild(column);//将元素添加到当前行。
}
这是我得到的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>
12:00
我不知道为什么rowspan在这里不起作用。有什么想法吗 var column=document.createElement(“td”)//创建一个元素。
var column = document.createElement("td"); //Creating a <td> element.
column.innerHTML = '3';
column.rowSpan = 2
document.getElementById("tr_demo").appendChild(column);
column.innerHTML='3';
column.rowSpan=2
document.getElementById(“tr_demo”).appendChild(列);
试试看
您是否验证了该
if
语句的内部是否正在执行?@JLRishe是的,我可以看到该表