javascript number_format(넘버포멧 콤마 찍기) > JavaScript

본문 바로가기

사이트 내 전체검색

뒤로가기 JavaScript

javascript number_format(넘버포멧 콤마 찍기)

페이지 정보

작성자 최고관리자 작성일 21-02-10 17:35 조회 6,105 댓글 0

본문

출처 : http://blog.naver.com/sch30217?Redirect=Log&logNo=150080597783


 function addCommas(nStr)
 {
        nStr += '';
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1)) {
                x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        return x1 + x2;
 }
 document.write(addCommas("1000000"));
 //result : 10,000,000[출처] javascript number format(넘버포멧 콤마 찍기)
 |작성자 무지개똥

댓글목록 0

등록된 댓글이 없습니다.

Copyright © beautipia.co.kr. All rights reserved.

contact : webmaster@beautipia.co.kr

PC 버전으로 보기