<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<p id="demo">单击按钮来显示该元素的标记名称</p>
<button>点我</button>
<script>
document.onclick=function(event){
let ev=event || window.event;
let selected=ev.target || ev.srcElement;
console.log(selected.tagName)
}
</script>
</body>
</html>
以上是为了兼容
网友评论