Script: Sliders - Show Value In Slider Handle
This article will show you how to program a slider with slider values within the Slider Handle
Background
You may have the need to have a Slider question display the Slider Values in the Slider handle itself. This can sometimes be used to aid in clarity for respondents when using these types of exercises.
Below is an example:
Instructions
- Program your 'Slider' question
- See article: Advanced Question: Slider
- Add the following code to the '+ Javascript' field
- See article: Adding JavaScript and/or CSS to a Question
- Add the following code to the '+ CSS' field
- See article: Adding JavaScript and/or CSS to a Question
- Make sure to test
/* SHOW VALUE IN SLIDER HANDLE */ jQuery(".cm-slider").on("slide", function(event, ui) { sliderValue = ui.value; jQuery(this).find(".ui-slider-handle").text(sliderValue); });
/* SHOW VALUE IN SLIDER HANDLE */ .cm-slider .ui-slider-handle { transition: none; } .cm-slider .ui-slider-handle { display: table; color: white; line-height: 2.25em; text-align: center; } .cm-slider-row__label-cell { padding-left: 2em; padding-right: 2em; }
Please Note
- This works best in 'V2 Themes'