我已经在div开始和结束标记中插入了许多表格格式,但是我试图让它在XSL文件中工作。我不想要一个切换div但是替换它的按钮。例如,它将像空白一样开始,然后一旦单击,将显示div - 表。忽略xsl:value-of标签。
任何人都可以帮助我吗?这是我的代码:
<div id="table1"><h3><b>Sydney @ 01/10/2017 15:30:45</b></h3>
<table width="40%" border="0">
<tr>
<td align="center" width="20%">
<xsl:value-of select="dayOfWeek" />
<i style="color:blue">FRI</i> 10/13
</td>
<td>
<xsl:value-of select="overall" />
<i>Partly sunny</i>
</td>
</tr>
<tr>
<td align="center" width="20%">
<xsl:value-of select="overallCode[@partlySunny]" />
<img src="http://www.uow.edu.au/~dong/w3/assignment/a7/partlySunny.png" />
</td>
<td>
<xsl:value-of select="highest" />
<xsl:value-of select="lowest" />
<b style="font-size:200%;">21°</b>/10°
</td>
</tr>
</table>
<script>
function myFunction() {
var tablex = document.getElementById("table1");
if (tablex.style.display === "none") {
tablex.style.display = "block";
} else {
tablex.style.display = "none";
}
}
</script>
答案 0 :(得分:0)
您可以通过添加:
来切换表格<button onclick="toggleTable();"></button>
function toggleTable() {
var tablex = document.getElementById("table1");
tablex.style.display = (tablex.style.display == "table") ? "none" : "table";
}
希望这会有所帮助:)