Javascript 拖动范围滑块-如何向输出中添加步骤和元素(逗号)
我正在使用,这是我到目前为止得到的: 在幻灯片中拖动时,它会给出一个输出 问题: 1) 拖动时,如何在数百个单位后的输出中添加“,”(逗号)Javascript 拖动范围滑块-如何向输出中添加步骤和元素(逗号),javascript,jquery,Javascript,Jquery,我正在使用,这是我到目前为止得到的: 在幻灯片中拖动时,它会给出一个输出 问题: 1) 拖动时,如何在数百个单位后的输出中添加“,”(逗号) -> Right now:-$ 4023 -> Required Output:- $ 4,023 -> Right now:-$ 4023 -> Required Output:- $ 4,023 2) 如何实现步骤,使其以100的倍数显示输出 -> Required Output:- $ 4.100 (multipl
-> Right now:-$ 4023
-> Required Output:- $ 4,023
-> Right now:-$ 4023
-> Required Output:- $ 4,023
2) 如何实现步骤,使其以100的倍数显示输出
-> Required Output:- $ 4.100 (multiple of 100)
-> Required Output:- $ 4.100 (multiple of 100)
var str = (4023/1000).toString().split('.');
str[1] = Math.floor(str[1]); //Looks like you want to round down. If not, use ceil() or round()
var out = parseFloat(str.join('.'));
这是我的密码:
JS:
$(function() {
new Dragdealer('just-a-slider', {
animationCallback: function(x, y) {
$('#dragValue').text(Math.round(x * 15000));
}
});
var availHeight = $('.content-body').outerHeight() -
$('.content-mask').outerHeight();
new Dragdealer('content-scroller', {
horizontal: false,
vertical: true,
yPrecision: availHeight,
animationCallback: function(x, y) {
$('.content-body').css('margin-top', -y * availHeight);
}
});
});
我相信这个问题已经得到了回答,但是用逗号
将“.”替换为“.”应该会起作用。我相信这个问题已经得到了回答,但用逗号表示 将“,”替换为“,”,它应该可以工作。您可以使用
。替换(/(\d)(?=(\d\d\d)+(?!\d))/g,“$1”)
来添加逗号,如果将基数除以100,(=150),您将在100中逐步执行,并可以根据需要在文本输出中附加额外的0
请参见此处的fiddle:您可以使用。替换(/(\d)(?=(\d\d\d)+(?!\d))/g,“$1”)
来添加逗号,如果将基数除以100,(=150),您将在100秒内完成,并可以根据需要在文本输出中附加额外的0
请参见此处的fiddle:问题:1)拖动时,如何在数百个单位后的输出中添加“,”(逗号)
-> Right now:-$ 4023
-> Required Output:- $ 4,023
-> Right now:-$ 4023
-> Required Output:- $ 4,023
4023/1000
2) 如何实现步骤,使其以100的倍数显示输出
-> Required Output:- $ 4.100 (multiple of 100)
-> Required Output:- $ 4.100 (multiple of 100)
var str = (4023/1000).toString().split('.');
str[1] = Math.floor(str[1]); //Looks like you want to round down. If not, use ceil() or round()
var out = parseFloat(str.join('.'));
问题:1)拖动时,如何在数百个单位后的输出中添加“,”(逗号)
-> Right now:-$ 4023
-> Required Output:- $ 4,023
-> Right now:-$ 4023
-> Required Output:- $ 4,023
4023/1000
2) 如何实现步骤,使其以100的倍数显示输出
-> Required Output:- $ 4.100 (multiple of 100)
-> Required Output:- $ 4.100 (multiple of 100)
var str = (4023/1000).toString().split('.');
str[1] = Math.floor(str[1]); //Looks like you want to round down. If not, use ceil() or round()
var out = parseFloat(str.join('.'));