我需要稍微修改一下 Bootstrap 滑块。
现在我有以下 HTML 代码以及 jQuery:
<div id="carousel-slider2" class="carousel slide bs-docs-carousel-example">
<ol class="carousel-indicators">
<li class="rooms active" data-target="#carousel-slider2" data-slide-to="0"></li>
<li class="rooms" data-target="#carousel-slider2" data-slide-to="1"></li>
<li class="rooms" data-target="#carousel-slider2" data-slide-to="2"></li>
<li class="rooms" data-target="#carousel-slider2" data-slide-to="3"></li>
<li class="rooms" data-target="#carousel-slider2" data-slide-to="4"></li>
<li class="ambience" data-target="#carousel-slider2" data-slide-to="5"></li>
<li class="ambience" data-target="#carousel-slider2" data-slide-to="6"></li>
<li class="ambience" data-target="#carousel-slider2" data-slide-to="7"></li>
<li class="ambience" data-target="#carousel-slider2" data-slide-to="8"></li>
<li class="ambience" data-target="#carousel-slider2" data-slide-to="9"></li>
<li class="ambience" data-target="#carousel-slider2" data-slide-to="10"></li>
<li class="holmen" data-target="#carousel-slider2" data-slide-to="11"></li>
<li class="holmen" data-target="#carousel-slider2" data-slide-to="12"></li>
<li class="holmen" data-target="#carousel-slider2" data-slide-to="13"></li>
<li class="holmen" data-target="#carousel-slider2" data-slide-to="14"></li>
<li class="holmen" data-target="#carousel-slider2" data-slide-to="15"></li>
<li class="holmen" data-target="#carousel-slider2" data-slide-to="16"></li>
</ol>
jQuery:
$('#carousel-slider2').on('slide.bs.carousel', function() {
console.log($("#carousel-slider2").children(".carousel-indicators").children("li"));
}
到目前为止,这有效,不是问题,我从 . 但我只想要具有“活动”类的那个。但由于某种原因,没有任何效果,不是原生 JS 方法“.getElementsByClassName”,也不是我知道的任何 jQuery 方法。有什么解决办法吗?