<script> var el = window.document.body; // 声明一个变量,默认值为body window.document.body.onmouseover = function(event){ el = event.target; // 鼠标每经过一个元素,就把该元素赋值给变量el // console.log(el.nodeName); console.log(el.id); } </script>