Alternating Slider Answer Colors | XM Community
Skip to main content
Solved

Alternating Slider Answer Colors

  • January 21, 2021
  • 2 replies
  • 60 views

Hello there!
I am trying to add alternating grey and white backgrounds to my slider answer options. I found this existing community question relating to matrix tables, and I was wondering if there was a way to edit the CSS to make this work for the slider question option within the platform. When asking a question with multiple measures, the lack of alternating colors makes the answers hard to differentiate from each other. Any help would be greatly appreciated!! I have attached an image of how the slider questions currently look. I would like to add alternating grey/white background color within each different answer option.
User:

Best answer by ahmedA

You can use the following code to set a different background colour for alternate choices:
sc = document.querySelectorAll(".slider-container:nth-child(odd)");
sc.forEach(item => item.style.backgroundColor = "#cccccc");
Or you could also add the same thing to CSS.

2 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Answer
  • January 22, 2021

You can use the following code to set a different background colour for alternate choices:
sc = document.querySelectorAll(".slider-container:nth-child(odd)");
sc.forEach(item => item.style.backgroundColor = "#cccccc");
Or you could also add the same thing to CSS.


  • Author
  • January 22, 2021

Ahmed, this work perfectly! Thank you so much!!