Jquery UI Slider next/previous value

669 views Asked by At

How i can get next or previous value from slider? I have slider with minimal allowed value: 0, maximum allowed value: 95, step: 3 and default value is: 10

$('#myslider').slider( "option", "min", 0 );
$('#myslider').slider( "option", "max", 95 );
$('#myslider').slider( "option", "step", 3 );
$('#myslider').slider( "option", "value", 10 );

How i can triggering to set or get next value. If my value is 30 next value will be 33, previous value will be 27

1

There are 1 answers

2
NightOwlPrgmr On

Since you can grab the current value using $("#myslider").slider("value"); I think you could find the previous and next values using the following:

var curr = $("#myslider").slider("value");
var step = $("#myslider").slider("option", "step");
var next = $("#myslider").slider("value", curr + step);
var prev = $("#myslider").slider("value", curr - step);