<html>
<body>
<p id="myP">单击该按钮可获取此元素的节点名称。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myP").nodeName;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>