代码如下:
点击(此处)折叠或打开
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title></title>
- <link rel="stylesheet" href="css/1.css" />
- <script type="text/javascript"src="js/jquery-1.9.1.js"></script>
- <script type="text/javascript"src="js/1.js"></script>
- </head>
- <body>
- <div id="kuang">
- <button class="btn tab1">tab1</button>
- <button class="btn tab2">tab2</button>
- <button class="btn tab2">tab3</button>
- </div>
- <div id="appear">
- <p id="content1">内容一</p>
- <p id="content2">内容二</p>
- <p id="content3">内容三</p>
-
- </div>
- </body>
- </html>
点击(此处)折叠或打开
- window.onload = function(){
-
-
- $(function(){
-
- $(function(){
-
-
- $("#kuang").children().click(function(){
- $(this).css("background","black").css("color","white").siblings().css("background","white").css("color","black");
- $("p").eq($(this).index()).show().siblings().hide();
- })
-
-
-
-
- })
-
-
-
- })
-
-
-
-
- }
点击(此处)折叠或打开
- *{
- margin:0;
- padding:0;
- }
- .btn{
- width:200px;
- height: 40px;
- margin-left:-10px;
- font-size: 20px;
- background: white;
- }
- .tab1{
- background: black;
- color: white;
- }
- #kuang{
- margin-left:40px;
- margin-top:40px;
- }
- #appear{
- width: 594px;
- height: 200px;
- outline: 1px solid black;
- margin-left:31px;
- font-size: 30px;
- }
- p{
- position: absolute;
- display: none;
- }
- #content1{
- display: block;
- }