Search code examples
jqueryjquery-uijquery-ui-slider

How to Get The Value Of UI in For Mat of Thousands-Separator


Can you please take a look at This Demo and let me know how I can get the value of slider in format of Thousands-Separator like 5,000 and all values on slide

<div id="slider1"></div>
<p>Your slider has a value of <span id="slider1-value"></span></p>
$("#slider1").slider(
{
            value:5000,
            min: 250000,
            max: 8000000,
            step: 50,
            slide: function( event, ui ) {
                $( "#slider1-value" ).html( ui.value );
            }
}
);

$( "#slider1-value" ).html(  $('#slider').slider('value') );

Solution

  • Use Jquery-Price-Format plugin. You can format current value like this:

                  $( "#slider1-value" ).html(ui.value ).priceFormat({
                    prefix: '',
                    centsSeparator: '.',
                    thousandsSeparator: ','
    
                  }); 
    

    See here for example.