我正在使用dragdealer.js,这是到目前为止我得到的:
在幻灯片中拖动时,它会提供输出,
问题:1)在拖动数百个单位后,如何在输出中添加“,”(逗号)?
-> Right now:-$ 4023
-> Required Output:- $ 4,023
2)如何执行步骤以使其显示输出为100的倍数?
-> Required Output:- $ 4.100 (multiple of 100)
这是我的代码:
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);
}
});
});
您可以使用.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")
添加逗号,如果将基数除以100(= 150),则将逐步输入100,并可以根据需要在文本输出中附加其他0。
在这里看到小提琴:http : //jsfiddle.net/535Pd/4/
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句