我目前的标记看起来像这样 -
<div class="carousel">
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
<div class="carousel-cell"></div>
</div>
当我有超过8个名为“carousel-cell”的孩子出现时,我正试图触发旋转木马插件,如果没有,那么什么都不做。是否有人对此进行了jquery调用?
答案 0 :(得分:4)
您可以检查jQuery对象的长度,如下所示:
if($('.carousel .carousel-cell').length >= 8) {
$('.carousel').yourPlugin();
}