| Reference | Downloads | Github

How to change the color of Slider single label?

Is it possible to change a single label color of slider (e.g. 1 in blue, 6 in red) directly in JS (online script)?

Best regards,

In PsychoPy you can do that like this:

mySlider.labels[0].color = 'red'  # label on the left
mySlider.labels[-1].color = 'blue'  # label on the right

and the PsychoJS lib does a pretty good job of mimicking the Python equivalent, so I think that would be worth a try (actually, I don’t know if negative indexing works in JS so you might need to count up instead)

unfortunately it doesn’t work in any variation I tried - I get message: TypeError: Cannot create property ‘color’ on string or experiment simply doesn’t start.

Hi @tomm, just needs a slight amendment. Try:

mySlider.labelObjs[0].color = 'red'  # etc