Home  >  Article  >  Web Front-end  >  Switching tab labels in jquery

Switching tab labels in jquery

零到壹度
零到壹度Original
2018-03-20 13:29:081293browse


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;}

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>

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>

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!

Statement:
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