Home > Web Front-end > JS Tutorial > body text

Switching tab labels in jquery

零到壹度
Release: 2018-03-20 13:29:08
Original
1309 people have browsed it


This article mainly introduces to you the specific steps and related operation skills of switching tab tags in jquery. Friends in need can refer to it. I hope it can help everyone.

css

body { cursor:default; -webkit-text-size-adjust:none; font-size:12px; font-family:Arial; background:#FFF; }
.clear { zoom:1; }
.clear:after { visibility:hidden; display:block; font-size:0; content:"1"; clear:both; height:0; }
.main { width:500px; margin:20px auto; }
.btn span { width:35px; text-align:center; color:#fff; background:#f00; cursor:pointer; margin:0 5px; display:block; float:left; }
.con { display:none; border:#033 1px solid; height:100px; width:200px; overflow: auto;}
Copy after login

html

<DIV class="main">   
 <DIV class="btn clear">   
      <span>1</span><span>2</span><span>3</span> 
  </DIV>
  <DIV class="con">
    第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个<br />第一个
 </DIV>
     <DIV class="con">第二个<br /> </DIV>
     <DIV class="con">第三个<br /> </DIV>
 </DIV>
Copy after login

js

  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">$(".con").eq(0).show();
$(".btn span").click(function() {
  var num = $(".btn span").index(this);
  $(".con").hide();
  $(".con").eq(num).show().slblings().hide();
})
</script>
Copy after login

The above is the detailed content of Switching tab labels in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template