Javascript on slider values (% symbol)

Melissa_E
Melissa_E Cleveland, OH Qubie ✭

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

Tagged:

Best Answer

  • Rich_Boits_Walker
    Rich_Boits_Walker Indianapolis
    Accepted Answer

    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.

Answers