<script>
function showhide(which){
if( which.style.display=="none"){
which.style.display=""
}else{
which.style.display="none"
}
}
</script>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#666666" onclick="showhide(content1)" style="color:white;cursor:hand">open1</td>
</tr>
<tr id="content1" style="display:none">
<td>content1</td>
</tr>
<tr>
<td bgcolor="#999999" onclick="showhide(content2)" style="color:white;cursor:hand">open2</td>
</tr>
<tr id="content2" style="display:none">
<td>content2</td>
</tr>
</table>
function showhide(which){
if( which.style.display=="none"){
which.style.display=""
}else{
which.style.display="none"
}
}
</script>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#666666" onclick="showhide(content1)" style="color:white;cursor:hand">open1</td>
</tr>
<tr id="content1" style="display:none">
<td>content1</td>
</tr>
<tr>
<td bgcolor="#999999" onclick="showhide(content2)" style="color:white;cursor:hand">open2</td>
</tr>
<tr id="content2" style="display:none">
<td>content2</td>
</tr>
</table>
| open1 |
| content1 |
| open2 |
| content2 |
博客展示了一段JavaScript代码和HTML表格代码。通过JavaScript的showhide函数,可根据元素的显示状态切换其显示或隐藏。HTML表格中,点击特定单元格能触发该函数,控制对应内容的显示与隐藏。
1735

被折叠的 条评论
为什么被折叠?



