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>
  • 相关阅读:
    端口扫描器的几种代码实现方案
    滴滴推理引擎IFX:千万规模设备下AI部署实践
    报名啦!第四届滴滴-IEEE未来精英论坛今夏来袭
    torch单机多卡重点:
    常见异常总结,入职阿里巴巴大概率面试题!!!
    龙小树 | R语言学习参考用书推荐
    英文写作常用网址
    LaTeX常用链接与资料
    LaTeX:算法模板
    崩溃中!我终于看明白了,什么是财富自由的底层逻辑!思维导图+笔记精华
  • 原文地址:https://www.cnblogs.com/stone5/p/9062524.html
Copyright © 2011-2022 走看看