How to stop propagating event from parent div to child div

前端 未结 5 2498
一向
一向 2021-02-20 01:36

I want to stop propagate event from parent div to child div in my html. Here a simple code what I\'m trying to do:

5条回答
  •  星月不相逢
    2021-02-20 01:55

    http://codepen.io/rakeshcode/pen/KrZdNo

    $(document).ready(function(){
      $(".arrow").click(function(){
      $(".row").slideToggle();
      
      });
    
    $(".btn").click(function(event){
       event.stopPropagation();
      //$(".btn").attr("href","www.yahoo.com")
    });
    })
    .btn {
      display: block;
      padding:15px;
      background-color:green;
      width:100px;
      margin-top:15px;
      text-decoration:none;
      margin-left:auto;
      margin-right:auto;
      
      
      
    }
    .arrow {
      cursor:pointer;
      text-align: center;
      padding:10px 0;
      font-size:15px;
      font-weight:bold;
      background-color:grey;
      margin-top:15px;
    }
    .container {
      max-width:600px;
      margin-left:auto;
      margin-right:auto; 
    }
    .close {
      height:75px;
      overflow:hidden;
      transition-duration: 0.3s;  
      transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
    }
    .open {
      height:215px;
      overflow: hidden;
      transition-property:height;
      -moz-transition-duration: 0.3s;
        -webkit-transition-duration: 0.3s;
        -o-transition-duration: 0.3s;
        transition-duration: 0.3s;  
      transition-timing-function: ease-in;
    }
    .up {
      background-color:red; 
    }
    .down {
      background-color:green;
    }
    
    
    Click here Click hereclick here
    The most effective plac elearning,’ they most likely don’t know this themselves.Well, the most effective place to start is to dig into what the person asking for this training, ACTUALLY needs. Because if they’re dumping a huge stack of content on your desk and giving you vague instructions to ‘turn it into elearning,’ they most likely don’t know this themselves.Well, the most effective place to start is to dig into what the person asking for this training.ACTUALLY needs. Because if they’re dumping a huge stack of content on your desk and giving you vague instructions to ‘turn it into elearning,’ they most likely don’t know this themselves.Well, the most effective place to start is to dig into what the person asking for this trainingACTUALLY needs. Because if they’re dumping a huge stack of content on your desk and giving you vague instructions to ‘turn it into elearning,’ they most likely don’t know this themselves.Well, the most effective place to start is to dig into what the person asking for this training

提交回复
热议问题