2

I want to reset the <div id="slider"> on clicking certain button.

<div> contains the slider (not important here).

is there any function like $(#slider).reset() or $(#slider).clear() or anything that clears the slider <div>?

codaniel
  • 5,263
  • 1
  • 23
  • 32

5 Answers5

2

to reset the slider

   $("#value-slider").slider("value", $("#value-slider").slider("option", "min") );

to empty a div

$("#value-slider").empty();
Kanishka Panamaldeniya
  • 17,302
  • 31
  • 123
  • 193
1

You can set a value, e.g. the minimum for this slider (0):

$('#slider').slider("value", 0);

Also see this example.

To set to the maximum:

$('#slider').slider('value', $("#slider").slider("option", "max"));

Also see my updated example.

=== UPDATE ===

I've updated my example once more. Now you can alert the current value and set the maximum to 30 too:

$('#slider').slider('option', 'max', 30);
...
alert($('#slider').slider('value'));
scessor
  • 15,995
  • 4
  • 43
  • 54
  • I want to set max value dynamically so I tried $("#slider").slider("max",30); which doesn't seem working –  May 17 '12 at 13:24
  • Does not work on range slider: Error: no such method 'value' for slider widget instance – Jonny Aug 05 '18 at 19:33
1

It's a bit difficult to judge what exactly you want, but have a look at this :

reset jquery slider

How to reset a jQuery UI slider?

http://forum.jquery.com/topic/slider-moving-slider-back-to-beginning-slider-reset-method

Example :

$("#slider").slider("value", $("#slider").slider("option", "min") );
Community
  • 1
  • 1
Marc Uberstein
  • 12,501
  • 3
  • 44
  • 72
0

There is a function empty() which can suffice your need. You can try

$("#slider").empty()

This will clear your <div> so that you can reset some other slider on it again

Taryn
  • 242,637
  • 56
  • 362
  • 405
veer7
  • 20,074
  • 9
  • 46
  • 74
  • kindly go through documentation http://docs.jquery.com/UI/Slider it's always often best way to follow the docs – veer7 May 17 '12 at 14:27
  • Scessor answered it right... do it as $("#slider").slider("option", max,30); neglecting "option" will not work... however it will work for "value" and "values" even if you neglect "option".. – veer7 May 17 '12 at 14:50
0

http://slidesjs.com/

Sliderjs:

To reset to first slide, Apply the following line in cancel or close button click event $('.pagination li:first a').click();

http://letslearn-kannan.blogspot.in/

kannan
  • 571
  • 2
  • 6
  • 8