user3459377 user3459377 - 8 months ago 40
jQuery Question

Slide images loaded from an array

I have a problem with sliding some images where the path is given from HTML and in JavaScript code is made a for, for all of these images.My problem is: how to display first image from array and by clicking on next button to switch for second, third and so on? NOW its shown only fourth image.

Here's my code and a fiddle:

function clickNextHandler(e)
if(progress <= 3){
pixie.src = "res/pixiDreapta.svg";
nextBtn.disabled = true;

if(progress == 4)
resetBtn.disabled = false;
svgItem.setAttribute("display", "none");

Answer Source

I did a little tweek on your code, it should help you:

var imgs = $('.eticheta');

$('.nextButton').on('click', function(){
    var visible = $('.eticheta:visible')
       , next =;


    if ($(next.get(0)).hasClass('eticheta') === false) {
        next = $('.eticheta:first');        

If instead of reset the image to the first one do you want to disable the button you should replace the code inside of the if statement to:

$('.nextButton').prop('disabled', true);