Is there a way to unset the value of a slider in jQuery Mobile 1.4.5?

81 Views Asked by At

I am using the following markup to display a slider with its value shown on its button:

<input type="range" name="my-slider" id="my-slider" min="1" max="5" step="0.5" value="" data-show-value="true"  class="ui-hidden-accessible" />

When the slider is first displayed, there is no value attached to the slider. Only until I move the button or programmatically set the value, does the slider change. For example,

$('#my-slider').val(someNumber).slider('refresh');

Is there a way to programmatically reset the value back to its original state (with no value) ? If I set it to null or '', the value becomes 1 (min). If I set it to 6, the value becomes 5 (max). But how do I unset it?

1

There are 1 best solutions below

0
On

Try this: $('#my-slider').slider('destroy').val('').slider();

Since there is no method to reset to an empty value you destroy the slider instance, set the value, then recreate the slider.

If you initially passed some config values into slider() then add that as well.