document.body

In this chapter you will learn:

  1. How to use document.body to get the body element

document.body

document.body returns the body element as HTMLBodyElement

<!DOCTYPE HTML> <!--from j av  a  2s .  com-->
<html> 
    <body> 
        <script> 
            document.writeln(document.body); 
        </script> 
    </body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to get document character set
Home » Javascript Tutorial » Document
Document Object
document.body
document.characterSet
document.charset
document.compatMode
document.cookie
document.defaultCharset
document.defaultView
getElementsByTagName(tagName)
document.getElementsByClassName
document.getElementsByName
document.images
document.lastModified
document.location
document.implementation
document.querySelectorAll
document.readyState
document.title
document.URL
document.writeln