JS编写点击页面弹出被点击的标签名
window.onload = function(){ var oBtn = document.getElementsByTagName("*"); for(var i=0;i<oBtn.length;i++){ oBtn[i].onclick = function(event){ console.log(this.tagName); //阻止事件冒泡 event.stopPropagation(); } } }
window.onload = function(){ var oBtn = document.getElementsByTagName("*"); for(var i=0;i<oBtn.length;i++){ oBtn[i].onclick = function(event){ console.log(this.tagName); //阻止事件冒泡 event.stopPropagation(); } } }