在这里,我希望当我的光滑滑块暂停时,我的视频也应暂停 错误:$(...)。get(...)。pause不是函数
$('.main-slide').on('afterChange', function(event, slick, currentSlide) {
var vid = $(slick.$slides[currentSlide]).find('.embed-video');
if (vid.length > 0) {
$('.main-slide').slick('slickPause');
$(vid).get(0).pause();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main-slide">
<div class="banner-image image slide1">
<img src="images/banner.jpg" />
</div>
<div class="banner-image image slide2">
<iframe class = "embed-video" id = "theVideo" src="https://www.youtube.com/embed/NsZ2nwWRH5c?rel=0&autoplay=1&controls=0&showinfo=0&enablejsapi=1" frameborder="0" allowfullscreen></iframe>
</div>
<div class="banner-image image slide3">
<iframe class = "embed-video" id = "theVideo" src="https://www.youtube.com/embed/NsZ2nwWRH5c?rel=0&autoplay=1&controls=0&showinfo=0&enablejsapi=1" frameborder="0" allowfullscreen></iframe>
</div>
</div>