Need JavaScript for one question not reading CSS code in survey style sheet | XM Community
Skip to main content

This is the CSS code I have on the Style Sheet to make all questions where N/A is an option, light gray

 

/*Makes the N/A column light gray on desktop*/
.last {
    background-color: rgba(0,0,0,0.05);
}

 

However I have one question multiple choice question that contains an N/A option but it is not presenting the light gray background as expected.

 

Any thoughts on what Java code I need to add to the question itself?

This is the CSS code I have on the Style Sheet to make all questions where N/A is an option, light gray

 

/*Makes the N/A column light gray on desktop*/
.last {
    background-color: rgba(0,0,0,0.05);
}

 

However I have one question multiple choice question that contains an N/A option but it is not presenting the light gray background as expected.

 

Any thoughts on what Java code I need to add to the question itself?

Check which is the last option. May be N/A is not the last.


@KBrady You code only work with table type of question (i.e Matrix table, side by side….). With multiple choice it’s gonna be different. Use this Java code to the question instead (i’m assuming N/A option is at the last)

Qualtrics.SurveyEngine.addOnload(function() {

var questionId = this.questionId;
var choiceLabels = jQuery("#" + questionId + " .LabelWrapper label");
choiceLabels.last().css("background-color", "rgba(0, 0, 0, 0.05)");
var lastChoiceInput = jQuery("#" + questionId + " input type='radio']").last();
lastChoiceInput.parent().css("background-color", "rgba(0, 0, 0, 0.05)");
});

Let me know if it work


Leave a Reply