-1

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
    Show what you've tried already. "Write my code for me." questions are generally regarded as bad on SO. – Marc Guiselin May 02 '16 at 17:15
  • wow thanks for your insightful answer, it really helped me a lot! – Alex Plahnz May 02 '16 at 17:47
  • If you want slider with auto play you can try this http://codepen.io/Creaticode/pen/xIfmw or this one http://codepen.io/suez/pen/ByvKXE study this codes and use it or change your slider using what you have learned. –  May 02 '16 at 17:52
  • Thanks El.oz i actually tried to understand the second slider you suggested, but i couldn't make it work, but i will check the first one! – Alex Plahnz May 02 '16 at 17:57
  • @AlexPlahnz Are you need controls in this slider ? i made a function to make it sliding auto but it will have a little bug if someone clicked on next/prev buttons... –  May 02 '16 at 20:33
  • @El.oz hi El, i don't think i really need the slider controls, so i can get rid of them if you managed to get it to autoplay, can i see the function you add? thanks a lot in advance!! – Alex Plahnz May 03 '16 at 15:03

1 Answers1

0

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.