Hello! I am trying to get the border color of the button to change when the slide changes (buttons are outside the slider)
This are the two different codes that I’m trying but i don’t know what I’m missing since neither of them work.
$w . onReady ( function () {
const blueColor = "#0C3C60" ;
const textColorActive = "#FFFFFF" ;
const whiteColor = "#FFFFFF" ;
const textColorInactive = "#0C3C60" ;
$w ( '#360MimicButton' ). onClick (() => {
$w ( "#TenderModelSlides" ). changeSlide ( 0 )
});
$w ( '#390HammerButton' ). onClick (() => {
$w ( "#TenderModelSlides" ). changeSlide ( 1 )
});
$w ( '#420ReefButton' ). onClick (() => {
$w ( "#TenderModelSlides" ). changeSlide ( 2 )
});
$w ( "#TenderModelSlides" ). onChange ( event => {
const buttonNames = [ "360Mimic" , "390Hammer" , "420Reef" ];
buttonNames . forEach ( buttonName => {
let button = $w ( "#" + buttonName + "Button" );
let index = $w ( "#TenderModelSlides" ). currentIndex ; // 2
if ( event . target . currentIndex === index ) {
button . style . borderColor = blueColor ;
button . style . color = textColorActive ;
} **else** {
button . style . borderColor = whiteColor ;
button . style . color = textColorInactive ;
}
});
});
$w . onReady ( function () {
$w ( '#360MimicButton' ). onClick (() => {
$w ( "#TenderModelSlides" ). changeSlide ( 0 )
});
$w ( '#390HammerButton' ). onClick (() => {
$w ( "#TenderModelSlides" ). changeSlide ( 1 )
});
$w ( '#420ReefButton' ). onClick (() => {
$w ( "#TenderModelSlides" ). changeSlide ( 2 )
});
});
$w . onReady (() => {
const buttons = [ “360MimicButton” , “390HammerButton” , “420ReefButton” ]; //use the property ID of the buttons; order them by the order of the slides.
const regularColor = “#FFFFFF” , highlighted = “#0C3C60” ;
$w ( “#TenderModelSlides” ). onChange ( event => {
let currentIndex = event . target . currentIndex ;
buttons . forEach ( e => $w ( “#” + e ). style . borderColor = regularColor );
$w ( “#” + buttons [ currentIndex ]). style . borderColor = highlighted ;
});
})
Basically, w hite when button is not active, and dark blue when the slide is active.