2

I am stuck at what I think is a really simple thing, basically I have the following code for a slider.

$( ".slider" ).slider({
  animate: true,
  range: "min",
  value: 0,
  min: 0,
  max: 255,
  step: 1,
  //this gets a live reading of the value and prints it on the page
  slide: function( event, ui ) {
    $( "#slider-result" ).html( ui.value );
  },
  //this updates the hidden form field so we can submit the data using a form
  change: function(event, ui) { 
    $('#112').attr('value', ui.value);
  }
});

All works fine and dandy, the thing I want to be able to do is make the value 0 again, resetting the slider. I have a little bit setup that does it in the physical form element, but I want the visual slider to show nothing as well.

2 Answers 2

1

If this is jQuery UI slider, then look at this:

http://api.jqueryui.com/slider/#option-value

// Get or set the value option, after initialization:

// getter
var value = $( ".selector" ).slider( "option", "value" );

// setter
$( ".selector" ).slider( "option", "value", 10 );
Sign up to request clarification or add additional context in comments.

Comments

0

You can specifically set the value of the slider

// This would reset the slider

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

1 Comment

Glad to have helped :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.