Scrolls the specified element into the visible area of the document.
By default, the top side of the element will be aligned to the top side of the closest scrollable ancestor element (in the DOM hierarchy), but you can change the alignment type with the first parameter of the scrollIntoView method. Sometimes exact alignment is not possible, in that case the scrollIntoView method scrolls the object to the position nearest to the required. After that, it repeats this procedure to the scrollable ancestor element recursively.
- The position of an element's scrollbars can be set or retrieved with the scrollLeft and scrollTop properties.
- To get the maximum scrolling positions, use the scrollWidth, scrollHeight and clientWidth, clientHeight properties.
- If you want to set the position of the document's scrollbars, use the scrollTo or scrollBy method.
You can find the related objects in the Supported by objects section below.
Optional. Boolean that indicates the type of the align.
One of the following values:
This method has no return value.
Example HTML code 1:
This example illustrates the use of the scrollIntoView method:
Did you find this example helpful?
User Contributed Comments