HTML通过js获得所点击标签的id




    
    
    
    


this is div 1
div2
this is div 3
this is div 4
this is div 5

获取点击标签id:

window.onload = function(){
    var target;
    document.onclick = function(e){
        target = e.target|| e.srcElement;
        alert(target.id);
    }
}

你可能感兴趣的:(HTML通过js获得所点击标签的id)