jquery-ui slider update value from code

maxlego picture maxlego · May 26, 2011 · Viewed 16.6k times · Source

i've got a problem with updating slider value from code. i have tried

$('#slider').slider('value', newValue);
$('#slider').val(newValue).slider();
$('#slider').val(newValue).slider('refresh');

and no result

any other suggestions

Answer

jams picture jams · May 26, 2011

here is a sample code

Determines the value of the slider, if there's only one handle. If there is more than one handle, determines the value of the first handle.

Code examples

Initialize a slider with the value option specified.
$( ".selector" ).slider({ value: 37 });
Get or set the value option, after init.
//getter
var value = $( ".selector" ).slider( "option", "value" );
//setter
$( ".selector" ).slider( "option", "value", 37 );