如何使此滑块代码在JavaScript中自动播放? [英] How can i make this slider code to autoplay in JavaScript?
问题描述
您好,我正在尝试让此滑块在Javascript中自动播放,但似乎无法正常工作,有人知道我能实现这一目标吗?
Hello I'm trying to get this slider to auto play in Javascript, but I can't seem to get it to work, Does anyone know how I can achieve this?
这是当前代码:
$(".button-next").click(function() {
var e = $(".feature-slide.active");
$(e).removeClass("active"),
$(e).next().addClass("active"),
$(".feature-slide").hasClass("active") || $(".feature-slide:first").addClass("active")
});
$(".button-prev").click(function() {
var e = $(".feature-slide.active");
$(e).removeClass("active"), $(e).prev().addClass("active"), $(".feature-slide").hasClass("active") || $(".feature-slide:last").addClass("active")
});
仅供参考:我不是开发人员,显然我也不是JavaScript专家,所以我在这里寻求帮助,因为您是专家,因此,如果您不打算给予积极的回应,请克制从回答或做出负面评论,谢谢!
FYI: i'm not a developer, and obviously i'm not a javascript expert, so i'm trying to get help here because you are the experts, so if you are not going to give a positive response, restrain from answering or making negative comments, thanks!
推荐答案
以下是代码 http: //codepen.io/El-Oz/pen/qZQePV
如果要更改幻灯片的速度,可以增加/减小JS代码中的timer
.
if you want to change speed of slide you can increase/decrease the timer
in JS code.
这篇关于如何使此滑块代码在JavaScript中自动播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!