How can i make this slider code to autoplay in Jav

2019-09-20 08:24发布

问题:

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?

I took the slider from here:

Here is the current code:

$(".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")
});

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!

回答1:

Here is the code http://codepen.io/El-Oz/pen/qZQePV

if you want to change speed of slide you can increase/decrease the timer in JS code.