VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/bootstrap-5-scrollspy-getinstance-method/

⇱ Bootstrap 5 Scrollspy getInstance() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Scrollspy getInstance() Method

Last Updated : 23 Jul, 2025

Bootstrap5 Scrollspy Methods are used to control the Scrollspy element with the help of Javascript and perform operations like disposing of, getting or creating the Scrollspy instance, refreshing the element, etc along with finding out useful data about the widget within Javascript.

Bootstrap 5 Scrollspy getInstance() Method

  • getInstance(): The Scrollspy instance linked to a DOM element may be obtained using this static function.

Syntax:

bootstrap.Scrollspy.getInstance(scrollspy-element)

Example 1: The code demonstrates how to implement the usage of the getInstance() Method using JavaScript on a Scrollspy with a navbar:

Output:


Example 2: The code demonstrates how to implement the usage of the getInstance() Method using JavaScript on a Scrollspy in a Nested Side Navbar:

Output:

Reference: https://getbootstrap.com/docs/5.0/components/scrollspy/#getinstance

Comment
Article Tags:

Explore