zoukankan      html  css  js  c++  java
  • jQuery—选项卡

    用jQuery实现选项卡,比原生JS更加简便,但是原理还是一样的:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    #wrap {
    400px;
    height: 300px;
    margin: 100px auto;
    }

    #wrap div {
    400px;
    height: 300px;
    border: #333 2px solid;
    line-height: 300px;
    text-align: center;
    font-size: 50px;
    display: none;
    }

    #wrap .active {
    background: red;
    color: #fff;
    }
    </style>
    <script src="jquery.min.js"></script>
    <script>
    $(function(){
    var aBtn = $('input');
    var aDiv = $('#wrap div');

    aBtn.click(function(){
    aBtn.removeClass('active');
    aDiv.hide();
    $(this).addClass('active');
    aDiv.eq($(this).index()).show();
    });
    });
    </script>
    </head>
    <body>
    <div id="wrap">
    <input type="button" value="按钮1" class="active">
    <input type="button" value="按钮2">
    <input type="button" value="按钮3">
    <div style="display: block;">div1</div>
    <div>div2</div>
    <div>div3</div>
    </div>
    </body>
    </html>
  • 相关阅读:
    单页应用 SPA(Sigle Page Aolication)
    初学数据库
    AJAX与跨域
    面向对象
    event、Dom
    HTML DOM Event 对象
    JavaScript RegExp 对象
    UNITY常用插件
    数据分析师
    VBA工作表排序转载
  • 原文地址:https://www.cnblogs.com/wang1593840378/p/6071767.html
Copyright © 2011-2022 走看看