简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <meta charset="utf-8" /> <link href="/static/next/css/tryit.css?v=2017082407" rel="stylesheet"/> <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 if (targ.nodeType == 3) // defeat Safari bug targ = targ.parentNode var tname tname=targ.tagName alert("You clicked on a " + tname + " element.") } </script> <link href="/static/next/css/tryit.css?v=2017082407" rel="stylesheet"/> <body onmousedown="whichElement(event)"> <p>在文档中点击某个位置。消息框会提示出您所点击的标签的名称。</p> <h3>这是标题</h3> <p>这是段落</p> <img src="/static/i/dom/eg_mouse2.jpg" /> <footer>简单教程,简单编程<br/>Copyright © 简单教程 www.twle.cn</footer>
运行结果: