<html>
<head>
<style type="text/css">
#tabs{
position:absolute;
width:250px;
margin-left:20px;
margin-bottom:30px;
font:20px;
//border:1px solid black; }
#basic{
font:18px;
width:100px;
//border:1px solid yellow;
background-color:lightblue;
cursor:hand;
z-index:1;
}
#score{
font:18px;
background-color:lightblue;
//border:1px solid yellow;
cursor:hand;
z-index:2
}
#section{
position:absolute;
width:400px;
height:400px;
font:20px;
margin-top:16px;
//border:1px solid black;
background-color:lightblue;
}
#section_basic{
widht:380px;
height:380px;
font:20px;
margin:10px;
background-color:lightblue;
//border:1px solid red;
z-index:3;
}
#section_score{
widht:380px;
height:380px;
font:20px;
margin:10px;
background-color:lightblue;
//border:1px solid red;
display:none;
z-index:3; }
</style>
<script>
function shows(obj)
{
alert(obj.id);//查看传进来的值是什么!
if(obj.id==basic)//这边怎么也不执行!
{
alert(sss);
document.getElementById("section_basic").style.display="block";
document.getElementById("section_score").style.display="none";
}
else
{
document.getElementById("section_basic").style.display="none";
document.getElementById("section_score").style.display="block";
}
}
</script>
</head>
<body>
<div id="tabs">
<span id="basic" onclick="shows(this);">基本信息 </span>
<span id="score" onclick="shows(this);">成绩 </span>
</div>
<div id="section">
<div id="section_basic">学生基本信息表 </div>
<div id="section_score">学生成绩信息表 </div>
</div>
</body>
</html>
代码没有贴好!
从贴了一下!
<head>
<style type="text/css">
#tabs{
position:absolute;
width:250px;
margin-left:20px;
margin-bottom:30px;
font:20px;
//border:1px solid black; }
#basic{
font:18px;
width:100px;
//border:1px solid yellow;
background-color:lightblue;
cursor:hand;
z-index:1;
}
#score{
font:18px;
background-color:lightblue;
//border:1px solid yellow;
cursor:hand;
z-index:2
}
#section{
position:absolute;
width:400px;
height:400px;
font:20px;
margin-top:16px;
//border:1px solid black;
background-color:lightblue;
}
#section_basic{
widht:380px;
height:380px;
font:20px;
margin:10px;
background-color:lightblue;
//border:1px solid red;
z-index:3;
}
#section_score{
widht:380px;
height:380px;
font:20px;
margin:10px;
background-color:lightblue;
//border:1px solid red;
display:none;
z-index:3; }
</style>
<script>
function shows(obj)
{
alert(obj.id);//查看传进来的值是什么!
if(obj.id==basic)//这边怎么也不执行!
{
alert(sss);
document.getElementById("section_basic").style.display="block";
document.getElementById("section_score").style.display="none";
}
else
{
document.getElementById("section_basic").style.display="none";
document.getElementById("section_score").style.display="block";
}
}
</script>
</head>
<body>
<div id="tabs">
<span id="basic" onclick="shows(this);">基本信息 </span>
<span id="score" onclick="shows(this);">成绩 </span>
</div>
<div id="section">
<div id="section_basic">学生基本信息表 </div>
<div id="section_score">学生成绩信息表 </div>
</div>
</body>
</html>
代码没有贴好!
从贴了一下!
祝你好运!!
basic会当成变量的
写成obj.id=="basic"