How do you shade every two rows in a matrix | XM Community
Question

How do you shade every two rows in a matrix


Badge

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

Userlevel 2
Badge +6

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
 

 

Userlevel 7
Badge +27

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");
});
});

 

Userlevel 2
Badge +6

@YW99  the answer off @TomG  works easier

Leave a Reply