//숫자 천단위 콤마 function numberFormat(inputNumber) { return inputNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } //숫자만 추출 function numberOnly(str){ var res; res = str.replace(/[^0-9]/g,""); return res; } //숫자 카운트 $('.counter').each(function() { var $this = $(this); var countTo = $this.attr('data-count'); if(countTo == undefined){ countTo = 10; } var duration = $this.attr('data-duration'); if(duration == undefined){ duration = 1000; } duration = parseInt(duration); $({ countNum: $this.text()}).animate({ countNum: countTo }, { duration: duration, easing:'linear', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); //alert('finished'); } }); }); //소수점 반올림 function roundToDecimal(value, decimalPlaces) { const factor = Math.pow(10, decimalPlaces); return Math.round(value * factor) / factor; // console.log(roundToDecimal(5.56789, 2)); // 5.57 }