Javascript on slider values (% symbol) | XM Community
Skip to main content
Is there a way to use javascript insert a percent symbol (%) after the values in a slider question?



So instead of the values reading 0, 10, 20, 30 etc on the example below, it would read 10%, 20%, 30%



!





Thank you!

Melissa
Hey @Melissa_E,

There is a css trick to get this done with the content property and the :after element. Go to the HTML view tab to the right of the edit box in the question editor and add the following script above your question text.



<style>

ul.numbers li::after {

content:"%";

}

</style>



Need to give a warning when using this however. The format of the generated html in the survey leaves white space after the content and the closing li tags... so this can/will cause wrapping issues on mobile.



If that's a concern you may need to look into looping over the li elements in the javascript editor and using the jquery $.trim(str) function.
This is perfect! Thank you SO much 😶 😶 😶

Is there a way to add the % sign over the number on the actual slider?


Leave a Reply