• jQuery基础 html+css3+jquery 点击按钮切换内容


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>点击按钮切换内容</title>
        <style type="text/css">
            .tab-menu ul{
                padding: 0;
                margin: 0;
            }
            .tab-menu ul li{
                display: inline-block;
                width: 200px;
                height: 40px;
                line-height: 40px;
                text-align: center;
                cursor: pointer;
            }
            .tab-menu ul li.active{
                background: #749dcf;
            }
            .tab-con div{
                width: 600px;
                height: 300px;
                background: #F2F2F2;
                border: 1px solid #749dcf;;
                display: none;
                padding: 15px;
     
            }
            .tab-con div:first-child{
                display: block;    
            }
        </style>
    </head>
    <body>
    <div class="tab-menu">
        <ul>
            <li class="active">按钮一</li>
            <li>按钮二</li>
            <li>按钮三</li>
        </ul>
    </div>
    <div class="tab-con">
        <div>内容一</div>
        <div>内容二</div>
        <div>内容三</div>
    </div>
    <script type="text/javascript" src="js/jquery.1.4.4.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.tab-menu li').click(function () {
                $(this).addClass('active').siblings().removeClass('active');
    //          $('.tab-top li').eq($(this).index()).addClass('active').siblings().removeClass('active');  tab按钮第二种写法
                var index=$(this).index();
                $(".tab-con div").eq(index).show().siblings().hide();     

    //注意着括号里面的div,如果标签下还有div包着,那就改成用类来代替
    }) }) </script>

    <!--整体第二种写法-->

    <!--<script type="text/javascript">
    $(function () {
    $('.tab-menu li').click(function () {
    $(this).addClass('active').siblings().removeClass('active');
    $(".tab-con div").eq($(this).index()).show().siblings().hide();
    //注意着括号里面的div,如果标签下还有div包着,那就改成用类来代替 })
    })
    </script>
    -->

      </body>
    </html>
  • 相关阅读:
    yii required 字段去除*号
    shtml用include加载文件,apache开启SSI,及shtml压缩
    门户站点用html或shtml文件格式的原因
    Apache配置shtml
    数据库迁移工具
    SQL SERVER2005 级联删除
    MySql级联删除和更新
    js只允许输入数字和小数点
    表格中的数据为空时,td的边框不显示
    MYSQL: Cannot delete or update a parent row: a foreign key constraint fails
  • 原文地址:https://www.cnblogs.com/hechunfeng/p/15257939.html
Copyright © 2020-2023  润新知