<table id="table1" style="display:block;">
<tr>
<td>表格内容</td>
</tr>
</table>
<input type="button" onclick="document.getElementById("table1").style.display='none'">
<tr>
<td>表格内容</td>
</tr>
</table>
<input type="button" onclick="document.getElementById("table1").style.display='none'">
<table id="t1" style="display:none" width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th rowspan="4" scope="col"> </th>
<th scope="col"> </th>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
var showmode=false;
function showandhidden(){
showmode = (showmode) ? false : true;
if(showmode){
document.getElementById("Week1").style.display="block";
}
if(!showmode){
document.getElementById("Week1").style.display="none";
}
}
</script>
<a href=# onclick=showandhidden()>Week1</a>
<div id=Week1 style="display:none">
<table>sdfsdfdfs
</table>
</div>你的那个让它消失还要双击,试试这个吧~!
假如表格的id=$var是一个变量
function showandhidden(id){
alert(id);
showmode = (showmode) ? false : true;
if(showmode){
document.getElementById(id).style.display="block";
}
if(!showmode){
document.getElementById(id).style.display="none";
}
}
</script>
id=$var
<a href=# onclick=showandhidden($var)>Week1</a>
<div id=$var style="display:none">
<table>sdfsdfdfs
</table>
</div>w为什么老是不行呢:(,另外我alert出来的,好像参数并没有传过来,而是一个[object]
老兄帮人帮到底吧,多谢了
<table id="t1" onclick="this.style.display='none'">
====document.getElementById("$var")
这是一个对象alert(id.innerHTML);就可以看到效果了 ,可以试试