我使用jquery完成了价格范围。但我无法在其价值上添加逗号 请在此处查看图像并输入图像说明。这是我的代码
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 250000,
max: 2000000,
values: [ 250000, 2000000 ],
slide: function( event, ui ) {
$( "#amount" ).val( "$" + ui.values[ 0 ] + " to $" + ui.values[ 1 ] );
}
});
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" to $" + $( "#slider-range" ).slider( "values", 1 ) );
});
</script>
&#13;
答案 0 :(得分:0)
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" to $" + $( "#slider-range" ).slider( "values", 1 ) );
到
$("#amount").val("$" + $("#slider-range").slider("values", 0).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") +
" to $" + $("#slider-range").slider("values", 1).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"));
和
$("#amount").val("$" + ui.values[ 0 ] + " to $" + ui.values[ 1 ] );
为:
$("#amount").val("$" + ui.values[0].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + " to $" + ui.values[1].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"));