Hla mus rau cov ntsiab lus tseem ceeb Hla mus rau docs navigation
Check
in English

Scrollspy

Hloov kho Bootstrap navigation lossis sau npe pawg raws li txoj haujlwm scroll los qhia tias qhov txuas twg tam sim no muaj nyob hauv qhov chaw saib.

Nws ua haujlwm li cas

Scrollspy toggles cov .activechav kawm ntawm thauj tog rau nkoj ( <a>) cov ntsiab lus thaum lub caij nrog cov idhais los ntawm lub thauj tog rau nkoj hrefyog scrolled rau hauv saib. Scrollspy yog qhov zoo tshaj plaws siv los ua ke nrog Bootstrap nav tivthaiv lossis npe pawg , tab sis nws kuj tseem yuav ua haujlwm nrog cov khoom thauj tog rau nkoj hauv nplooj ntawv tam sim no. Nov yog qhov nws ua haujlwm li cas.

  • Txhawm rau pib, scrollspy yuav tsum muaj ob yam: navigation, pab pawg, lossis cov kab txuas yooj yim, ntxiv rau lub thawv scrollable. Lub thawv scrollable tuaj yeem yog cov khoom siv <body>los yog kev cai nrog lub teeb heightthiab overflow-y: scroll.

  • Nyob rau hauv lub thawv scrollable, ntxiv data-bs-spy="scroll"thiab data-bs-target="#navId"qhov twg navIdyog qhov tshwj xeeb idntawm kev sib txuas navigation. Nco ntsoov kuj suav nrog tabindex="0"kom paub meej cov keyboard nkag.

  • Raws li koj scroll lub thawv "spied", ib .activechav kawm ntxiv thiab tshem tawm los ntawm kev sib txuas thauj tog rau nkoj hauv cov kev sib txuas. Cov ntawv txuas yuav tsum muaj idlub hom phiaj daws tau, txwv tsis pub lawv tsis quav ntsej. Piv txwv li, ib qho <a href="#home">home</a>yuav tsum sib haum rau qee yam hauv DOM nyiam<div id="home"></div>

  • Lub hom phiaj cov ntsiab lus uas tsis pom yuav raug ignored. Saib cov ntsiab lus tsis pom hauv qab no.

Piv txwv

Scroll thaj tsam hauv qab ntawm navbar thiab saib qhov hloov pauv hauv chav kawm. Qhib cov ntawv qhia zaub mov dropdown thiab saib cov khoom dropdown tseem ceeb thiab.

Thawj nqe lus

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Ob nqe lus

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Peb lub taub hau

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Plaub nqe lus

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Tshooj tsib

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

<nav id="navbar-example2" class="navbar bg-light px-3 mb-3">
  <a class="navbar-brand" href="#">Navbar</a>
  <ul class="nav nav-pills">
    <li class="nav-item">
      <a class="nav-link" href="#scrollspyHeading1">First</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" href="#scrollspyHeading2">Second</a>
    </li>
    <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
      <ul class="dropdown-menu">
        <li><a class="dropdown-item" href="#scrollspyHeading3">Third</a></li>
        <li><a class="dropdown-item" href="#scrollspyHeading4">Fourth</a></li>
        <li><hr class="dropdown-divider"></li>
        <li><a class="dropdown-item" href="#scrollspyHeading5">Fifth</a></li>
      </ul>
    </li>
  </ul>
</nav>
<div data-bs-spy="scroll" data-bs-target="#navbar-example2" data-bs-root-margin="0px 0px -40%" data-bs-smooth-scroll="true" class="scrollspy-example bg-light p-3 rounded-2" tabindex="0">
  <h4 id="scrollspyHeading1">First heading</h4>
  <p>...</p>
  <h4 id="scrollspyHeading2">Second heading</h4>
  <p>...</p>
  <h4 id="scrollspyHeading3">Third heading</h4>
  <p>...</p>
  <h4 id="scrollspyHeading4">Fourth heading</h4>
  <p>...</p>
  <h4 id="scrollspyHeading5">Fifth heading</h4>
  <p>...</p>
</div>

Nested nav

Scrollspy kuj ua haujlwm nrog nested .navs. Yog ib lub zes .nav, .activenws niam nws txiv kuj yuav .active. Scroll qhov chaw nyob ib sab ntawm lub navbar thiab saib qhov hloov pauv hauv chav kawm.

Yam khoom 1

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Nco ntsoov tias JavaScript plugin sim xaiv qhov zoo ntawm txhua yam uas yuav pom. Ntau lub hom phiaj pom scrollspy tib lub sijhawm tuaj yeem ua rau qee qhov teeb meem.

Nqe 1-1

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Nco ntsoov tias JavaScript plugin sim xaiv qhov zoo ntawm txhua yam uas yuav pom. Ntau lub hom phiaj pom scrollspy tib lub sijhawm tuaj yeem ua rau qee qhov teeb meem.

Nqe 1-2

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Nco ntsoov tias JavaScript plugin sim xaiv qhov zoo ntawm txhua yam uas yuav pom. Ntau lub hom phiaj pom scrollspy tib lub sijhawm tuaj yeem ua rau qee qhov teeb meem.

Yam khoom 2

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Nco ntsoov tias JavaScript plugin sim xaiv qhov zoo ntawm txhua yam uas yuav pom. Ntau lub hom phiaj pom scrollspy tib lub sijhawm tuaj yeem ua rau qee qhov teeb meem.

Yam khoom 3

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Nco ntsoov tias JavaScript plugin sim xaiv qhov zoo ntawm txhua yam uas yuav pom. Ntau lub hom phiaj pom scrollspy tib lub sijhawm tuaj yeem ua rau qee qhov teeb meem.

Nqe 3-1

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Nco ntsoov tias JavaScript plugin sim xaiv qhov zoo ntawm txhua yam uas yuav pom. Ntau lub hom phiaj pom scrollspy tib lub sijhawm tuaj yeem ua rau qee qhov teeb meem.

Nqe 3-2

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Nco ntsoov tias JavaScript plugin sim xaiv qhov zoo ntawm txhua yam uas yuav pom. Ntau lub hom phiaj pom scrollspy tib lub sijhawm tuaj yeem ua rau qee qhov teeb meem.

<div class="row">
  <div class="col-4">
    <nav id="navbar-example3" class="h-100 flex-column align-items-stretch pe-4 border-end">
      <nav class="nav nav-pills flex-column">
        <a class="nav-link" href="#item-1">Item 1</a>
        <nav class="nav nav-pills flex-column">
          <a class="nav-link ms-3 my-1" href="#item-1-1">Item 1-1</a>
          <a class="nav-link ms-3 my-1" href="#item-1-2">Item 1-2</a>
        </nav>
        <a class="nav-link" href="#item-2">Item 2</a>
        <a class="nav-link" href="#item-3">Item 3</a>
        <nav class="nav nav-pills flex-column">
          <a class="nav-link ms-3 my-1" href="#item-3-1">Item 3-1</a>
          <a class="nav-link ms-3 my-1" href="#item-3-2">Item 3-2</a>
        </nav>
      </nav>
    </nav>
  </div>

  <div class="col-8">
    <div data-bs-spy="scroll" data-bs-target="#navbar-example3" data-bs-smooth-scroll="true" class="scrollspy-example-2" tabindex="0">
      <div id="item-1">
        <h4>Item 1</h4>
        <p>...</p>
      </div>
      <div id="item-1-1">
        <h5>Item 1-1</h5>
        <p>...</p>
      </div>
      <div id="item-1-2">
        <h5>Item 1-2</h5>
        <p>...</p>
      </div>
      <div id="item-2">
        <h4>Item 2</h4>
        <p>...</p>
      </div>
      <div id="item-3">
        <h4>Item 3</h4>
        <p>...</p>
      </div>
      <div id="item-3-1">
        <h5>Item 3-1</h5>
        <p>...</p>
      </div>
      <div id="item-3-2">
        <h5>Item 3-2</h5>
        <p>...</p>
      </div>
    </div>
  </div>
</div>

Sau npe pawg

Scrollspy kuj ua haujlwm nrog .list-groups. Scroll qhov chaw nyob ib sab ntawm cov npe pawg thiab saib cov chav kawm hloov pauv.

Yam khoom 1

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Yam khoom 2

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Yam khoom 3

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Yam khoom 4

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

<div class="row">
  <div class="col-4">
    <div id="list-example" class="list-group">
      <a class="list-group-item list-group-item-action" href="#list-item-1">Item 1</a>
      <a class="list-group-item list-group-item-action" href="#list-item-2">Item 2</a>
      <a class="list-group-item list-group-item-action" href="#list-item-3">Item 3</a>
      <a class="list-group-item list-group-item-action" href="#list-item-4">Item 4</a>
    </div>
  </div>
  <div class="col-8">
    <div data-bs-spy="scroll" data-bs-target="#list-example" data-bs-smooth-scroll="true" class="scrollspy-example" tabindex="0">
      <h4 id="list-item-1">Item 1</h4>
      <p>...</p>
      <h4 id="list-item-2">Item 2</h4>
      <p>...</p>
      <h4 id="list-item-3">Item 3</h4>
      <p>...</p>
      <h4 id="list-item-4">Item 4</h4>
      <p>...</p>
    </div>
  </div>
</div>

Yooj yim anchors

Scrollspy tsis txwv rau nav cov khoom thiab cov npe pawg, yog li nws yuav ua haujlwm ntawm cov <a>khoom thauj tog rau nkoj hauv cov ntaub ntawv tam sim no. Scroll thaj tsam thiab saib cov .activechav kawm hloov.

Yam khoom 1

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Yam khoom 2

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Yam khoom 3

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Yam khoom 4

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

Yam khoom 5

Nov yog qee qhov chaw muab cov ntsiab lus rau nplooj ntawv scrollspy. Nco ntsoov tias thaum koj nqes mus rau nplooj ntawv, qhov tsim nyog navigation txuas yog tseem ceeb. Nws rov ua dua thoob plaws hauv qhov piv txwv. Peb pheej ntxiv qee qhov piv txwv ntxiv ntawm no los hais txog qhov scrolling thiab highlighting.

<div class="row">
  <div class="col-4">
    <div id="simple-list-example" class="d-flex flex-column gap-2 simple-list-example-scrollspy text-center">
      <a class="p-1 rounded" href="#simple-list-item-1">Item 1</a>
      <a class="p-1 rounded" href="#simple-list-item-2">Item 2</a>
      <a class="p-1 rounded" href="#simple-list-item-3">Item 3</a>
      <a class="p-1 rounded" href="#simple-list-item-4">Item 4</a>
      <a class="p-1 rounded" href="#simple-list-item-5">Item 5</a>
    </div>
  </div>
  <div class="col-8">
    <div data-bs-spy="scroll" data-bs-target="#simple-list-example" data-bs-offset="0" data-bs-smooth-scroll="true" class="scrollspy-example" tabindex="0">
      <h4 id="simple-list-item-1">Item 1</h4>
      <p>...</p>
      <h4 id="simple-list-item-2">Item 2</h4>
      <p>...</p>
      <h4 id="simple-list-item-3">Item 3</h4>
      <p>...</p>
      <h4 id="simple-list-item-4">Item 4</h4>
      <p>...</p>
      <h4 id="simple-list-item-5">Item 5</h4>
      <p>...</p>
    </div>
  </div>
</div>

Cov ntsiab lus tsis pom

Lub hom phiaj cov ntsiab lus uas tsis pom yuav raug tsis quav ntsej thiab lawv cov khoom siv nav hia yuav tsis tau txais .activechav kawm. Scrollspy piv txwv pib nyob rau hauv ib qho tsis pom wrapper yuav tsis quav ntsej tag nrho cov ntsiab lus. Siv txoj hauv refreshkev los kuaj xyuas cov ntsiab lus pom thaum lub wrapper pom.

document.querySelectorAll('#nav-tab>[data-bs-toggle="tab"]').forEach(el => {
  el.addEventListener('shown.bs.tab', () => {
    const target = el.getAttribute('data-bs-target')
    const scrollElem = document.querySelector(`${target} [data-bs-spy="scroll"]`)
    bootstrap.ScrollSpy.getOrCreateInstance(scrollElem).refresh()
  })
})

Kev siv

Los ntawm cov ntaub ntawv attributes

Txhawm rau yooj yim ntxiv scrollspy tus cwj pwm rau koj qhov topbar navigation, ntxiv data-bs-spy="scroll"rau lub caij koj xav soj ntsuam (feem ntau qhov no yuav yog <body>). Tom qab ntawd ntxiv tus data-bs-targetcwj pwm nrog lub idnpe lossis chav kawm ntawm niam txiv lub ntsiab ntawm ib qho Bootstrap .navtivthaiv.

<body data-bs-spy="scroll" data-bs-target="#navbar-example">
  ...
  <div id="navbar-example">
    <ul class="nav nav-tabs" role="tablist">
      ...
    </ul>
  </div>
  ...
</body>

Ntawm JavaScript

const scrollSpy = new bootstrap.ScrollSpy(document.body, {
  target: '#navbar-example'
})

Kev xaiv

Raws li kev xaiv tuaj yeem dhau los ntawm cov ntaub ntawv tus cwj pwm lossis JavaScript, koj tuaj yeem ntxiv ib qho kev xaiv npe rau data-bs-, xws li hauv data-bs-animation="{value}". Nco ntsoov hloov cov ntaub ntawv ntawm lub npe xaiv los ntawm " camelCase " mus rau " kebab-case " thaum dhau cov kev xaiv ntawm cov ntaub ntawv cwj pwm. Piv txwv li, siv data-bs-custom-class="beautifier"es tsis txhob data-bs-customClass="beautifier".

Raws li ntawm Bootstrap 5.2.0, tag nrho cov khoom txhawb nqa qhov kev sim khaws tseg cov ntaub ntawv tus cwj pwm data-bs-configuas tuaj yeem ua tsev yooj yim kev teeb tsa raws li JSON txoj hlua. Thaum ib qho khoom muaj data-bs-config='{"delay":0, "title":123}'thiab data-bs-title="456"tus cwj pwm, tus titlenqi kawg yuav yog 456thiab cov ntaub ntawv sib cais yuav dhau los ntawm cov txiaj ntsig tau muab rau data-bs-config. Ntxiv mus, cov ntaub ntawv uas twb muaj lawm muaj peev xwm ua tsev JSON qhov tseem ceeb xws li data-bs-delay='{"show":0,"hide":150}'.

Lub npe Hom Default Kev piav qhia
rootMargin txoj hlua 0px 0px -25% Kev Sib Tham Observer rootMargin siv tau units, thaum xam scroll txoj hauj lwm.
smoothScroll boolean false Ua kom du scrolling thaum tus neeg siv nyem rau ntawm qhov txuas uas hais txog ScrollSpy observables.
target hlua, DOM element null Qhia meej lub caij siv Scrollspy plugin.
threshold array [0.1, 0.5, 1] IntersectionObserver pib siv tau input, thaum xam scroll txoj hauj lwm.

Cov kev xaiv tsis raug xaiv

Txog rau v5.1.3 peb tau siv offset& methodkev xaiv, uas tam sim no deprecated thiab hloov los ntawm rootMargin. Txhawm rau kom rov qab sib raug zoo, peb yuav txuas ntxiv txheeb xyuas qhov muab offsetrau rootMargin, tab sis qhov no yuav raug tshem tawm hauv v6 .

Cov txheej txheem

Txoj kev Kev piav qhia
dispose Destroys ib lub caij scrollspy. (Tshem cov ntaub ntawv khaws cia ntawm DOM lub caij)
getInstance Txoj kev zoo li qub kom tau txais qhov piv txwv scrollspy txuam nrog DOM keeb.
getOrCreateInstance Txoj kev zoo li qub kom tau txais qhov piv txwv scrollspy txuam nrog DOM lub caij, lossis tsim ib qho tshiab yog tias nws tsis tau pib.
refresh Thaum ntxiv lossis tshem tawm cov ntsiab lus hauv DOM, koj yuav tsum hu rau tus qauv tshiab.

Nov yog ib qho piv txwv uas siv txoj kev refresh:

const dataSpyList = document.querySelectorAll('[data-bs-spy="scroll"]')
dataSpyList.forEach(dataSpyEl => {
  bootstrap.ScrollSpy.getInstance(dataSpyEl).refresh()
})

Cov xwm txheej

Kev tshwm sim Kev piav qhia
activate.bs.scrollspy Qhov xwm txheej no tua hluav taws ntawm lub caij scroll thaum twg lub thauj tog rau nkoj yog qhib los ntawm scrollspy.
const firstScrollSpyEl = document.querySelector('[data-bs-spy="scroll"]')
firstScrollSpyEl.addEventListener('activate.bs.scrollspy', () => {
  // do something...
})