Home > Software engineering >  Change color of label when slide is active
Change color of label when slide is active

Time:09-18

Can sombody help me I'm trying to change the color of the text active slide.

So if Slide 1 is active then the text "Slide 1" at the bottom of the screen should turn yellow the other 2 stay white.

and if slide 2 is active "Slide 2" should turn yellow enz.

the code that i am using is: "https://codepen.io/omairatiq/pen/wvBoGaE"

Sorry for my bad englis.

CodePudding user response:

You can customize this script in this way. In function Interval() in js file, above the this line

$('.inProgress'   progressBarIndex).css({
    width: percentTime   "%"
});

Add this part

$('.inProgress').parent().parent().removeClass("yellow-text");
$('.inProgress'   progressBarIndex).parent().parent().addClass("yellow-text");

And add this line in css file

.yellow-text h3{
  color :yellow;
}

Finally , Full Interval function is

function interval() {
    if (($('.slider .slick-track div[data-slick-index="'   progressBarIndex   '"]').attr("aria-hidden")) === "true") {
        progressBarIndex = $('.slider .slick-track div[aria-hidden="false"]').data("slickIndex");
        startProgressbar();
    } else {
        percentTime  = 1 / (time   5);

        $('.inProgress').parent().parent().removeClass("yellow-text");
        $('.inProgress'   progressBarIndex).parent().parent().addClass("yellow-text");

        $('.inProgress'   progressBarIndex).css({
            width: percentTime   "%"
        });
        if (percentTime >= 100) {
            $('.single-item').slick('slickNext');
            progressBarIndex  ;
            if (progressBarIndex > 2) {
                progressBarIndex = 0;
            }
            startProgressbar();
        }
    }
}

Check here in detail https://codepen.io/jamesjo29155352/pen/NWjOrrx

  • Related