<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选项卡</title>
<style type="text/css">
*{
padding: 0;
margin: 0;
}
#tab ul li{
display: inline;
font-size: 30px;
padding-left: 30px;
/*获得焦点是,出现手型图标*/
cursor: pointer;
}
img{
width: 33.33%;
float: left;
margin-top: 30px;
}
.conceal{
display: none;
}
</style>
</head>
<body>
<div id="tab">
<ul>
<li class="on">网站开发</li>
<li class="off">公众号开发</li>
<li class="off">App开发</li>
</ul>
<div class="show">
<img src="img/case/web/web1.jpg">
<img src="img/case/web/web2.jpg">
<img src="img/case/web/web3.jpg">
<img src="img/case/web/web4.jpg">
<img src="img/case/web/web5.jpg">
<img src="img/case/web/web6.jpg">
</div>
<div class="conceal">
<img src="img/case/order/order1.jpg">
<img src="img/case/order/order2.jpg">
<img src="img/case/order/order3.jpg">
</div>
<div class="conceal">
<img src="img/case/app/app1.jpg">
<img src="img/case/app/app2.jpg">
<img src="img/case/app/app3.jpg">
<img src="img/case/app/app4.jpg">
<img src="img/case/app/app5.jpg">
<img src="img/case/app/app6.jpg">
</div>
</div>
<div>
<p>测试</p>
</div>
<script type="text/javascript">
window.onload =function(){
var Mytab = document.getElementById("tab");
var Myul = Mytab.getElementsByTagName("ul")[0];
var Myli = Myul.getElementsByTagName("li");
var MyDiv = Mytab.getElementsByTagName("div");
for (var i = 0; i < Myli.length; i++) {
Myli[i].index = i;
Myli[i].onclick =function(){
for (var j = 0; j < Myli.length; j++) {
Myli[j].className="off";
MyDiv[j].className="conceal";
}
this.className="on";
MyDiv[this.index].className="show";
}
}
}
</script>
</body>
</html>
网友评论