Sử dụng document.documentElement thuộc tính trong JavaScript để lấy documentElement của tài liệu, tức là nodeName. Bạn có thể thử chạy mã sau để triển khai document.documentElement thuộc tính trong JavaScript -
Ví dụ
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<p>Demo Text</p>
<script>
document.body.style.backgroundColor = "gray";
var a = document.documentElement.nodeName;
document.write("Node Name: "+a);
</script>
</body>
</html>