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

    <!DOCTYPE html>

    <htmllang="en">

    <head>

    <metacharset="UTF-8"><title>choseCart</title>

    <script src="https://cdn.bootcss.com/jquery/1.8.3/jquery.js"></script>

    <styletype="text/css">

      *{margin: 0;padding: 0;}

      li{list-style: none;}

      #menu {height: 30px;}

      #menu li{float: left;background: #999;color: #fff;cursor: pointer;border:2px solid #666;}

      #menu .active{border-right-color: #666;border-left-color: #666;border-top-color: blue;border-bottom-color: #fff}

      #pannel div:nth-of-type(1){background: green; 335px;height: 200px;}

      #pannel div:nth-of-type(2){background: blue; 335px;height: 200px;}

      #pannel div:nth-of-type(3){background: black; 335px;height: 200px;}

      #pannel div:nth-of-type(4){background: red; 335px;height: 200px;}

      #pannel div{display: none;}

      #pannel .active{display: block;}

    </style><scripttype="text/javascript">

      $(function(){

        let oLi=$('#menu li');

        /*oLi.bind('click',function() {

          let iIndex=$(this).index();oLi.removeClass('active').eq(iIndex).addClass('active');

          $('#pannel div').removeClass('active').eq(iIndex).addClass('active');

        });*/

      oLi.hover(function(){

        let iIndex=$(this).index();

        oLi.removeClass('active').eq(iIndex).addClass('active');

        $('#pannel div').removeClass('active').eq(iIndex).addClass('active');

        })

      })

    </script>

    </head>

    <body>

      <div id="box">

        <ul id="menu">

          <li class="active">第一个按钮</li>

          <li>第二个按钮</li>

          <li>第三个按钮</li>

          <li>第四个按钮</li>

        </ul>

        <div id="pannel">

          <div class="active"></div>

          <div></div>

          <div></div>

          <div></div>

        </div>

      </div>

      

    </body>

    </html>

      回来再总结下思路吧:

      1:CSS布局要点:默认按钮和内容区域第一个为active状态,

      2:写jQuery时通过addClass()/removeClass()来改变卡片的状态;

    焦大叔叔
  • 相关阅读:
    性能分析和优化思维导图
    linux系统性能监控命令sar
    Postman发送json格式的数据
    postman的collection上传文件
    [转]可任意自定义的UITableViewCell
    时间函数举例2
    输入年月日判断这是一年中的第几天.
    时间函数举例1
    打印出国际象棋棋盘.
    打印楼梯同时在楼梯上方打印出两个笑脸.
  • 原文地址:https://www.cnblogs.com/tiny-jiao/p/6432227.html
Copyright © 2011-2022 走看看