Thursday, September 4, 2025
HomeLanguagesJavascriptHTML DOM document scrollingElement Property

HTML DOM document scrollingElement Property

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:

let 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>neveropen</h1>
    <button onclick="get()">
        Get ScrollingElement
    </button>
 
    <script type="text/javascript">
        function get() {
            let Elm = document.scrollingElement;
            Elm.scrollTop = 0;
            console.log(Elm)
        }
    </script>
</body>
   
</html>


Output:

 

Supported Browsers:

  • Google Chrome 44
  • Edge 12
  • Firefox 48
  • Opera 31
  • Safari 9
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS