当某个幻灯片具有活动类名时,如何运行javascript函数
我试图在滑动条上创建一个功能,因此当滑动条上的第二张幻灯片的类名为“swiper slide active”时,它会提醒用户他们正在第二张幻灯片上 这是解决我问题的密码笔当某个幻灯片具有活动类名时,如何运行javascript函数,javascript,jquery,html,css,swiper,Javascript,Jquery,Html,Css,Swiper,我试图在滑动条上创建一个功能,因此当滑动条上的第二张幻灯片的类名为“swiper slide active”时,它会提醒用户他们正在第二张幻灯片上 这是解决我问题的密码笔 您需要在滑梯事件中调用您的警报代码,滑梯未处于就绪状态 e、 g 有关更多事件,请参阅。您需要在滑动时调用您的警报代码,即swiper not on ready Function(刷卡器未就绪功能)事件 e、 g 有关更多事件,请参见您想要实现的可能是: 如果.second child处于活动状态,则发出警报 所以你需要一些东
您需要在滑梯事件中调用您的警报代码,滑梯未处于就绪状态 e、 g
有关更多事件,请参阅。您需要在滑动时调用您的警报代码,即swiper not on ready Function(刷卡器未就绪功能)事件 e、 g
有关更多事件,请参见您想要实现的可能是: 如果
.second child
处于活动状态,则发出警报
所以你需要一些东西来搭配这个
// Event will be triggered after animation to other slide (next or previous).
// @see https://idangero.us/swiper/api/#events
swiper.on('slideChangeTransitionEnd', function() {
// check, if active slide has a class of 'second-child'
if (this.slides[this.realIndex].classList.contains("second-child")) {
alert("active");
}
})
或
此处不涉及jQuery您想要实现的可能是: 如果
.second child
处于活动状态,则发出警报
所以你需要一些东西来搭配这个
// Event will be triggered after animation to other slide (next or previous).
// @see https://idangero.us/swiper/api/#events
swiper.on('slideChangeTransitionEnd', function() {
// check, if active slide has a class of 'second-child'
if (this.slides[this.realIndex].classList.contains("second-child")) {
alert("active");
}
})
或
此处不涉及jQuery可能重复查看文档,特别是myswider.realIndex,您可能会感兴趣@yunzen我认为不可能重复查看文档,特别是mySwiper.realIndex,您可能对它感兴趣@yunzen我不认为soI就“准备就绪时的文档”的使用键入了评论,但后来我意识到我不知道该活动是什么样子。@yunzen老实说,我不知道vanillajs,我会继续的it@satsvelke什么是
rnd
?我键入了一条关于“准备就绪时的文档”用法的评论,但后来我意识到我不知道该事件应该是什么样子。@yunzen老实说,我不知道vanillajs,我会继续it@satsvelke什么是rnd
?
// Event will be triggered after animation to other slide (next or previous).
// @see https://idangero.us/swiper/api/#events
swiper.on('slideChangeTransitionEnd', function() {
// check, if active slide has a class of 'second-child'
if (this.slides[this.realIndex].classList.contains("second-child")) {
alert("active");
}
})
swiper.on('slideChangeTransitionEnd', function() {
if (this.realIndex == 1) { // second slide, because of zero indexed counting
alert("active");
}
})