How do you shade every two rows in a matrix | XM Community
Skip to main content
Question

How do you shade every two rows in a matrix

  • May 2, 2024
  • 3 replies
  • 61 views

Forum|alt.badge.img

I have a matrix with 8 rows. I need to shade rows 3 and 4 and rows 7 and 8 in a different color. Can you please share how do I do this?

 

Where exactly does the custom code get pasted?

3 replies

RickB
Level 4 ●●●●
Forum|alt.badge.img+22
  • Level 4 ●●●●
  • 128 replies
  • May 2, 2024

Hey @YW99 
mabey this code can work

Qualtrics.SurveyEngine.addOnload(function() {

    // Target rows 3 and 4

    jQuery("#QID1 #3, #QID1 #4").css("background-color", "lightblue");

    

    // Target rows 7 and 8

    jQuery("#QID1 #7, #QID1 #8").css("background-color", "lightgreen");

});


Replace "QID1" with the actual ID of your matrix question. Also, ensure that you replace "3", "4", "7", and "8" with the IDs of the rows in your matrix question.

select te question and then javascript of the question.


 

The first line off the code you will also find it there. Overwrite that line with this code
 

 


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6083 replies
  • May 2, 2024

Here is an easier way. You don’t have to lookup or replace anything:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .ChoiceRow").each(function(i) {
if(i%4 >1) jQuery(this).css("background-color","#eee");
});
});

 


RickB
Level 4 ●●●●
Forum|alt.badge.img+22
  • Level 4 ●●●●
  • 128 replies
  • May 2, 2024

@YW99  the answer off @TomG  works easier