diff options
Diffstat (limited to 'site/content/docs/5.1/components/scrollspy.md')
-rw-r--r-- | site/content/docs/5.1/components/scrollspy.md | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/site/content/docs/5.1/components/scrollspy.md b/site/content/docs/5.1/components/scrollspy.md index e48cc06f27..21b6a5e2f4 100644 --- a/site/content/docs/5.1/components/scrollspy.md +++ b/site/content/docs/5.1/components/scrollspy.md @@ -319,7 +319,7 @@ To easily add scrollspy behavior to your topbar navigation, add `data-bs-spy="sc ### Via JavaScript ```js -var scrollSpy = new bootstrap.ScrollSpy(document.body, { +const scrollSpy = new bootstrap.ScrollSpy(document.body, { target: '#navbar-example' }) ``` @@ -371,10 +371,9 @@ To keep backwards compatibility, we will continue to parse a given `offset` to ` Here's an example using the refresh method: ```js -var dataSpyList = Array.prototype.slice.call(document.querySelectorAll('[data-bs-spy="scroll"]')) -dataSpyList.forEach(function (dataSpyEl) { - bootstrap.ScrollSpy.getInstance(dataSpyEl) - .refresh() +const dataSpyList = document.querySelectorAll('[data-bs-spy="scroll"]') +dataSpyList.forEach(dataSpyEl => { + bootstrap.ScrollSpy.getInstance(dataSpyEl).refresh() }) ``` @@ -387,8 +386,8 @@ dataSpyList.forEach(function (dataSpyEl) { {{< /bs-table >}} ```js -var firstScrollSpyEl = document.querySelector('[data-bs-spy="scroll"]') -firstScrollSpyEl.addEventListener('activate.bs.scrollspy', function () { +const firstScrollSpyEl = document.querySelector('[data-bs-spy="scroll"]') +firstScrollSpyEl.addEventListener('activate.bs.scrollspy', () => { // do something... }) ``` |