How to move answer boxes | XM Community
Skip to main content

I have a single question with four answer options displayed horizontally. I am trying to move them so that they align with an HTML table which appears directly above.
I have managed to successfully use this syntax to move the first and last answer boxes around.
Qualtrics.SurveyEngine.addOnload(function()
{
var el1 = $(this.questionId).select('label.SingleAnswer').first();
el1.style.marginLeft = "80%";

    var el4 = $(this.questionId).select('label.SingleAnswer').last();
    el4.style.marginLeft = "200%";
});
How do I select the 2nd and 3rd answer boxes? I've tried $(this.questionId).select('label.SingleAnswer').eq(1); for the second, but this doesn't work.

Try using below:
var el2 = jQuery("#"+this.questionId).find('label.SingleAnswer:eq(1)');
var el3 = jQuery("#"+this.questionId).find('label.SingleAnswer:eq(2)');


Thanks rondev, but unfortunately that didn't run. I also tried the following, but they didn't work either.
 $(this.questionId).find('label.SingleAnswer:eq(1)');
 $(this.questionId).select('label.SingleAnswer:eq(1)');


@TriciaB,

  1. You can't intermix Prototypejs ($) and jQuery. .find() and .eq() aren't prototypejs functions. They only work on jQuery objects.

  2. rondev's code is correct, but I think you have the wrong element. A horizontal MC uses a table, so you want to align the table cells. You would probably be better off adding/moving everything into the same table.



Leave a Reply