第1个回答 2012-10-14
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<input type="button" id="_switch" value="显示成绩表" />
<div id="_tablea">
<table cellpadding="0" cellspacing="0" border="1">
<tr>
<th>姓名</th>
<th>信息</th>
</tr>
<tr>
<td>撒旦法</td>
<td>斯蒂芬斯蒂芬</td>
</tr>
</table>
</div>
<div id="_tableb" style="display:none;">
<table cellpadding="0" cellspacing="0" border="1">
<tr>
<th>姓名</th>
<th>成绩</th>
</tr>
<tr>
<td>撒旦法</td>
<td>111</td>
</tr>
</table>
</div>
<script>
document.getElementById('_switch').onclick = function(){
if (this.value=='显示成绩表'){
this.value='显示学生信息表';
document.getElementById('_tablea').style.display='none';
document.getElementById('_tableb').style.display='block';
}
else {
this.value='显示成绩表';
document.getElementById('_tablea').style.display='block';
document.getElementById('_tableb').style.display='none';
}
};
</script>
</body>
</html>本回答被提问者和网友采纳
第2个回答 2012-10-16
那样做一个TAB选项卡比较好,让用户可见两个选项选择性切换更直观。
JS的tab百度搜索有很多,这里也不贴一堆乱七八糟的代码了。
第3个回答 2012-10-16
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<input type="button" id="btn" value='显示学生信息'/>
<div id="mark">mark</div>
<div id="info" style='display:none;'>info</div>
<script type="text/javascript" charset="utf-8">
function _(s){
return typeof s=='string'?document.getElementById(s):null;
}
var obtn=_('btn');
obtn.onclick=function(){
if(this.value=='显示学生信息'){
_('mark').style.display='none';
_('info').style.display='block';
this.value='显示学生成绩';
}else{
_('mark').style.display='block';
_('info').style.display='none';
this.value='显示学生信息';
}
}
</script>
</body>
</html>