jq jobs

A, jQuery exercises

  1. This page is found in the id i1tag

    $('#i1')
  2. This page find all h2labels

    $('h2')
  3. This page find all inputlabels

    $('input')
  4. This page find all styles class has c1a label

    $('.c1')
  5. This page find all styles class has btn-defaulta label

    $('.btn-default')
  6. This page find all styles class has c1tags and all h2tags

    $('.c1,h2')
  7. This page find all styles class has c1a label and id is p3the label

    $('.c1,#p3')
  8. This page find all styles class has c1tags and all styles class has btna label

    $('.c1,.btn')
  9. Find on this page formall the tags in the inputtag

    $('form input')
  10. This page was found wrapped labelin the label inputtag

    $('label input')
    // 等价于
    $('label').find('input')
  11. Found on this page immediately labelbehind the label inputtag

    $('label').next('input')   
  12. Id to find this page in p2all its peer behind the label and the lilabel

    $('#p2').nextAll('li')
  13. Id is found f1inside the label first input tag

    $('#f1 input').first()
  14. Find the id value of my-checkboxthe internal tag last input label

    $('#my-checkbox input').last()
  15. Find the id value of my-checkboxthe internal tag is not selected the input tag

    $('#my-checkbox input').not(':checked')
  16. Find all containing inputthe label labeltag

    $('label input')

Second, the left side of the menu bar

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="x-ua-compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <title>左侧菜单示例</title>
  <style>
    .left {
      position: fixed;
      left: 0;
      top: 0;
      width: 20%;
      height: 100%;
      background-color: rgb(47, 53, 61);
    }
    .menu {
      color: white;
    }

    .title {
      text-align: center;
      padding: 10px 15px;
      border-bottom: 1px solid #23282e;
    }

    .items {
      background-color: #181c20;
    }
    .item {
      padding: 5px 10px;
      border-bottom: 1px solid #23282e;
    }

    .hide {
      display: none;
    }
  </style>
</head>
<body>

<div class="left">
  <div class="menu">
    <div class="item">
      <div class="title">菜单一</div>
      <div class="items">
        <div class="item">111</div>
        <div class="item">222</div>
        <div class="item">333</div>
    </div>
    </div>
    <div class="item">
      <div class="title">菜单二</div>
      <div class="items hide">
      <div class="item">111</div>
      <div class="item">222</div>
      <div class="item">333</div>
    </div>
    </div>
    <div class="item">
      <div class="title">菜单三</div>
      <div class="items hide">
      <div class="item">111</div>
      <div class="item">222</div>
      <div class="item">333</div>
    </div>
    </div>
  </div>
</div>
<div class="right"></div>


<script>
  $(".title").click(function (){  
    $(".items").addClass("hide");  
    $(this).next().removeClass("hide");
      
    // $(this).next().removeClass('hide').parent().siblings().find('.items').addClass('hide')
  });
</script>

Guess you like

Origin www.cnblogs.com/shin09/p/11893194.html