Efficient Javascript for coloring the NPS question | XM Community
Skip to main content
Question

Efficient Javascript for coloring the NPS question

  • June 13, 2023
  • 0 replies
  • 130 views

JohannesCE
Level 6 ●●●●●●
Forum|alt.badge.img+12

Hi! I'm looking for a more efficient way to color the NPS question options. 

Right now I use the following script:

/* Color the NPS question */

#QID10 td.LabelContainer:nth-child(1) label:hover,
#QID10 td.LabelContainer:nth-child(1) label.q-checked {
background-color: #E73F12 !important;
color: #ffffff;
}

#QID10 td.LabelContainer:nth-child(2) label:hover,
#QID10 td.LabelContainer:nth-child(2) label.q-checked {
background-color: #EE5C1C !important;
color: #ffffff;
}

etc...

It works fine, but I end up with a lot of lines in my CSS editor, 5 for each label container.

Is there a more efficient way to do this, perhaps with JS in the question itself?