Answer the question
In order to leave comments, you need to log in
How to set slider value dynamically?
There is a code
$( "#slider-range-max" ).slider({<br>
range: "max",<br>
min: 1,<br>
<br>
max:61,<br>
<br>
value: 1,<br>
step: 1,<br>
slide: function( event, ui ) {<br>
<br>
var val = ui.value;<br>
<br>
if(val > 10){<br>
<br>
ui.value = ui.value + 3;<br>
<br>
<br>
$( "#amount" ).val(ui.value);<br>
<br>
<br>
<br>
// $(this).slider('option','max',500);<br>
<br>
<br>
}<br>
else { $( "#amount" ).val( ui.value); <br>
}
Answer the question
In order to leave comments, you need to log in
Then
var valueShow;
if(ui.value>10){
valueShow=10 + (ui.value-10)*3 ;
}else{
valueShow=ui.value;
}
$( "#amount" ).val(valueShow);
$(function() {
$( "#slider-range-max" ).slider({
range: "max",
min: 1,
max: 61,
value: 1,
slide: function( event, ui ) {
if( ui.value >= 10) {
$( this ).slider( "option", "step", 3 );
}
else {
$( this ).slider( "option", "step", 1 );
}
$( "#amount" ).val( ui.value );
}
});
$( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) );
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question