How can i make this slider code to autoplay in JavaScript?

强颜欢笑 提交于 2020-01-07 09:03:54

问题


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.



来源:https://stackoverflow.com/questions/36987872/how-can-i-make-this-slider-code-to-autoplay-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!