先记录一下坑: 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; } }) }