W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <script> function whichElement(e) { var targ; if (!e) { var e = window.event; } if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; } var tname; tname = targ.tagName; alert("You clicked on a " + tname + " element."); } </script> </head> <body onmousedown="whichElement(event)"> <p>单击文档中的某处。警报框将提醒您单击的元素的名称。</p> <h3>这是标题</h3> <img border="0" src="/i/photo/smile.gif" alt="Smiley" width="128" height="128"> <p>这是段落。</p> </body> </html>