zoukankan      html  css  js  c++  java
  • t-6. 点解切换div内容

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style type="text/css">
            *{margin:0pxpadding:0px;}
            atext-decoration:none; }  ul{list-style:none;}
            .shop_all{width:300pxheight:300pxoverflowhidden;}
            .shop_all_a{width:300pxheight:300pxbackground:pink;}
            .list_shop{width:1000pxoverflowhiddenmargin:auto;}
            .list_shop p{width:200pxheight:30pxline-height:30px;}
            .shop_click{width:500pxoverflowhidden;}
            .shop_click li{width:100pxheight:40pxborder:1px solid redmargin:0px 10pxtext-align:centerline-height:40pxfloat:leftcursor:pointer;}
            .red{background:redcolor:#fff;}
        </style>
    </head>
    <body>


    <ul class="shop_click">
            <li class="red">A款</li>
            <li>B款</li>
            <li>c</li>
    </ul>


    <div class="shop_all">
        <div class="shop_all_a" style="display:block;">
            aaaaaa
        </div>

        <div class="shop_all_a" style="display:none;">
            bbbbbb
        </div>
        <div class="shop_all_a" style="display:none;">
            cccccc
        </div>
    </div>
     
        <script src="jquery.js"></script>
        <script>
       
            $('.shop_click li').click(function(){
               $(this).addClass('red').siblings().removeClass('red');
               //找到“red”类  找到每个div的所有同辈元素  从匹配的元素中删除 'red' 类
               $('.shop_all_a').eq($(this).index()).show().siblings().hide(); 
               //获取这个匹配的元素 显示它  同类的元素隐藏//
           })
    </script>
     
    </body>
    </html>
  • 相关阅读:
    slice()、substring()、substr()的区别用法
    程序员如何快速上手一个自己不太熟悉的新项目?有什么技巧?
    计算重复字符串长度
    计算机视觉算法研发岗招聘要求
    C++进阶STL-2
    C++进阶STL-1
    拼硬币
    序列找数
    寻找合法字符串
    字符串是否由子串拼接
  • 原文地址:https://www.cnblogs.com/stone5/p/9062524.html
Copyright © 2011-2022 走看看