Javascript spilling over across questions within block | XM Community
Skip to main content


For one of my surveys, I have a block with three sliders, each in its own question of that block. Each slider is almost identical to every other slider on that block, with the exception of: 1) difference in descriptive text, 2) a different descriptive text in the the javascript as highlighted in bold capitals below:
  jQuery(".statement-container div").eq(0).append(" DESCRIPTIVE TEXT ");
   jQuery("#"+this.questionId+" ul.numbers li").each(function() { this.innerHTML = this.innerHTML.replace("-",""); });
});
However, when previewing, all the descriptive texts from the javascripts are listed at the first question. I've included screenshots of code and the problem as it looks in preview.
I haven't been able to find any guidance on how to eliminate spillover between the questions, making sure that I can add a descriptive text individually to each slider. I'd be incredibly grateful for help or insights here - I'm a total java novice so I have a hard time identifying exactly where I've messed up. Any help?

Skærmbillede 2022-04-05 kl. 12.23.52.pngSkærmbillede 2022-04-05 kl. 12.24.11.png

Make the selector in you first line of code

"#"+this.questionId+" .statement-container div"
.


Thank you! That solved it!


Leave a Reply