event.stopPropagation

先记录一下坑:
    var btn = test.getElementsByTagName('label');
        btn[0].active = 'active';
        for(var i = 0; i < btn.length; i++){
          btn[i].addEventListener('click',function(e){
            var ev = e || window.event;
            ev.stopPropagation();
            console.log(this)
            if(!this.active){
              this.className ='btn btn-default mt10 active';
              this.active = 'active';
            }else{
              this.className = 'btn btn-default mt10';
              this.active = 0;
            }

          })
        }


posted @ 2017-08-14 10:22  子龙_子龙  阅读(1)  评论(0编辑  收藏  举报