Number.prototype.toPercent = function(n){n = n || 0;return ( Math.round( this * Math.pow( 10, n + 2 ) ) / Math.pow( 10, n ) ).toFixed( n ) + '%';}
var A=0.358975, B=0.25554;
alert([A, A.toPercent(3), B, B.toPercent()].join('\n'));
js实现小数转百分比
最新推荐文章于 2024-01-26 16:45:00 发布