scrollIntoView() method is used to move the screen to a target element.
- In the above example, a list is created and for one list item we have given an id(id_b), it is the item where the windows has to be scrolled.
- In the function, we are getting the particular list item using its id(document.getElementById("id_b");) and storing in elem variable.
- And using the scrollIntoView property the windows will be scrolled to the particular list item(elem.scrollIntoView();).
- The windows will be scrolled to the particular list item.