Complete the code to add ScrollSpy to the <body> element.
<body data-bs-spy=[1] data-bs-target="#navbar-example"> <!-- content --> </body>
The data-bs-spy attribute must be set to "scroll" to enable ScrollSpy on the element.
Complete the code to specify the ScrollSpy target navigation element.
<body data-bs-spy="scroll" data-bs-target=[1]> <!-- content --> </body>
The data-bs-target attribute should point to the ID of the navigation element that ScrollSpy will update. Here, #navbar-example is correct.
Fix the error in the ScrollSpy initialization code.
<nav id="navbar-example" class="navbar"> <ul class="nav nav-pills"> <li class="nav-item"> <a class="nav-link active" href="#section1">Section 1</a> </li> </ul> </nav> <script> var scrollSpy = new bootstrap.ScrollSpy(document.body, { target: [1] }) </script>
The target option must be a CSS selector string. Using "#navbar-example" correctly points to the navigation element by its ID.
Fill both blanks to create a ScrollSpy-enabled <nav> with correct attributes.
<nav id="navbar-example" class="navbar navbar-light bg-light px-3" [1]=[2]> <ul class="nav nav-pills flex-column"> <li class="nav-item"> <a class="nav-link active" href="#item-1">Item 1</a> </li> </ul> </nav>
data-bs-target instead of data-bs-spy for the first blank."navbar" instead of "scroll".The data-bs-spy attribute enables ScrollSpy, and it must be set to "scroll" to listen to scroll events.
Fill all three blanks to create a ScrollSpy with correct target and offset.
<body data-bs-spy=[1] data-bs-target=[2] data-bs-offset=[3] tabindex="0"> <!-- page content --> </body>
The data-bs-spy must be "scroll", the data-bs-target should point to the navigation ID #navbar-example, and data-bs-offset sets the scroll offset in pixels, here "100".
