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>
  • 相关阅读:
    Bootstrap入门(八)组件2:下拉菜单
    Bootstrap入门(七)组件1:字体图标
    Bootstrap入门(六)按钮和图片
    Bootstrap入门(五)表单
    Bootstrap入门(四)表格
    Bootstrap入门(三)<p>标签的css样式
    Bootstrap入门(二)栅格
    Bootstrap入门(一)准备
    shellcode加密与解密
    功能强大而又简单易学的编程语言Python
  • 原文地址:https://www.cnblogs.com/stone5/p/9062524.html
Copyright © 2011-2022 走看看