Skip to content
Related Articles

Related Articles

HTML DOM document scrollingElement Property

Improve Article
Save Article
  • Last Updated : 08 Jul, 2022
Improve Article
Save Article

The scrollingElement property of the document returns a reference to the element that scrolls the document.

In standards mode, this is the root element of the document. Whereas in quirks mode, It returns the HTML body element or NULL.

Syntax:

var elem = document.scrollingElement;

Return Value:

  • In standards mode, It returns the root element of the document.
  • In quirks mode, It returns the HTML body element or NULL.

Example: In this Example, we are getting the scrolling element using this property.

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
    <button onclick="get()">
        Get ScrollingElement
    </button>
 
    <script type="text/javascript">
        function get() {
            var Elm = document.scrollingElement;
            Elm.scrollTop = 0;
            console.log(Elm)
        }
    </script>
</body>
 
</html>

Output:

Before Click the Button:

After Click the Button:

Supported Browsers:

  • Google Chrome 44
  • Edge 12
  • Firefox 48
  • Opera 31
  • Safari 9
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!