0

I'm using the jQuery UI plugin called "range slider" (see http://jqueryui.com/slider/#range) and I'm wondering how to change the intervals from '1' to '10', so that a user gets 10, 20, 30, ...until 1000 when using the slider.

This is my code:

$(function() {
    $( "#slider-range" ).slider({
        range: true,
        min: 1,
        max: 1000,
        values: [ 75, 300 ],
        slide: function( event, ui ) {

            var offset1 = $(this).children('.ui-slider-handle').first().offset();
            var offset2 = $(this).children('.ui-slider-handle').last().offset();
            $(".tooltip1").css('top',offset1.top).css('left',offset1.left).show();
            $(".tooltip2").css('top',offset2.top).css('left',offset2.left).show();


            $('#min').val("€ " + ui.values[ 0 ]);
            $('#max').val("€ " + ui.values[ 1 ]);

        },
        stop:function(event,ui){
            $(".tooltip").hide();
        }
    });

$('#min').change(function(){
    $( "#slider-range" ).slider( "values", 0, $('#min').val()  );
});
$('#max').change(function(){
    $( "#slider-range" ).slider( "values", 1, $('#max').val()  );
});

});

Thanks in advance for your help!

1 Answer 1

1

The step option does exactly what you described:

$( "#slider-range" ).slider({
    range: true,
    min: 0,
    max: 1000,
    values: [ 100, 300 ],
    step: 10
}

Note that I've changed min to 0 as it's better to have a number divisible by the step.

Here's a fiddle: http://jsfiddle.net/gL42daep/

Also note that the code in the question (in the fiddle) has some inconsistencies, possibly as a side effect of posting it here: #max and #min, when setting from the slider, get an extra euro sign with their numeric value; however you need to delete that if you want to use those numeric values to set the slider.

Sign up to request clarification or add additional context in comments.

Comments

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.