Blogger Information
Blog 250
fans 3
comment 0
visits 322883
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js-选项卡的基本原理
梁凯达的博客
Original
1493 people have browsed it

<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 <meta http-equiv="X-UA-Compatible" content="ie=edge" />
 <title>Document</title>
 <style type="text/css">
  li{
   float: left;
   list-style: none;
   text-align: center;
   width: 100px;
   line-height: 100px;
   background: #7CFC00;
   border:#0000FF 1px solid;
  }
  div{
   width: 300px;
   line-height: 100px;
   background: #FFFF00;
   text-align: center;
  }
 </style>
</head>
<body>
 <li onclick="func(0)">点击1</li>
 <li onclick="func(1)">点击2</li>
 <li onclick="func(2)">点击3</li>
 <div>
  我这个是个div <br />
  换一行就可以了
 </div>
 <div style="display: none;">
  这个是div2 <br />
  同样换一行就可以了
 </div>
 <div style="display: none;">
  这个是div3 <br />
  换一行就行了
 </div>
 <script type="text/javascript">
  function func(a){
   //获取整个集合
   var divs = document.getElementsByTagName('div');
   for(var i=0;i<divs.length;i++){
    if(a == i){
     divs[i].style.display='block';
    }else{
     divs[i].style.display='none';
    }
   }
  }
 </script>
</body>
</html>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post