fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body onclick="myFunction()"> <p>点击文档中任意一元素输出元素标签名。</p> <input type="text" value="输入字段"> <button>按钮</button> <p id="demo"></p> <script> function myFunction() { var x = document.activeElement.tagName; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
运行结果