Jquery ui range slider get current minimum and maximum values

by mrjordy

HTML

<p>
<label for="amount">Rate:</label>
<input type="text" id="amount" readonly>
</p>
<div id="slider-range"></div>

CSS

#accordion {
    margin:20px;
    height:300px;
}

JavaScript

$(function() {
    var minPriceIn = 0;
    var maxPriceIn = 999;
    var currentMinValue = 33;
    var currentMaxValue = 500;
    
    $( "#slider-range" ).slider({
        range: true,
        min: minPriceIn,
        max: maxPriceIn,
        values: [ currentMinValue, currentMaxValue ],
        slide: function( event, ui ) {
            $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
            currentMinValue = ui.values[ 0 ];
            currentMaxValue = ui.values[ 1 ];
        },
        stop: function( event, ui ) {
            currentMinValue = ui.values[ 0 ];
            currentMaxValue = ui.values[ 1 ];
            alert('currentMinValue = '+currentMinValue+' currentMaxValue = '+currentMaxValue);
        }
    });

    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});