<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>选项卡效果(包含CSS修饰)</title>
<style>
div{
display:none;
margin-left:-2px;
margin-top:-3px;
}
span a:hover{
color:#FF0;
}
span a{
text-decoration:none;
}
</style>
</head>
<body>
<table border="0">
<tr>
//选项按钮
<td width="90" onmousedown="choose(1)" bgcolor="#FF9999"><span><a href="#">动漫</a></span></td>
<td width="90" onmousedown="choose(2)" bgcolor="#FF9999"><span><a href="#">科幻</a></span></td>
<td width="90" onmousedown="choose(3)" bgcolor="#FF9999"><span><a href="#">机器人</a></span></td>
<td width="90" onmousedown="choose(4)" bgcolor="#FF9999"><span><a href="#">神话</a></span></td>
</tr>
<tr>
<td colspan="4">
//从本机选择四张图片
<div id="1" style="width:440px; height:200px"><img src="../1.jpg" width="400px" height="200px"/></div>
<div id="2" style="width:440px; height:200px"><img src="../2.jpg" width="400px" height="200px"/></div>
<div id="3" style="width:440px; height:200px"><img src="../1.jpg" width="400px" height="200px" /></div>
<div id="4" style="width:440px; height:200px"><img src="../2.jpg" width="400px" height="200px" /></div>
</td>
</tr>
</table>
</body>
</html>
<script language="javascript" type="text/javascript">
function choose(dnum){
for(var i=1;i<=4;i++){
if(i==dnum){
//当选择的DIV的值与其中任意一个相等时,则显示该i的图片或选项
document.getElementById(i).style.display="block";
}else{
//其他的隐藏
document.getElementById(i).style.display="none";
}
}
}
</script>
显示效果 :点击的是“动漫”按钮:
点击“科幻”按钮: