-
인풋 가격 콤마찍기JAVASCRIPT 2020. 6. 11. 17:12
$(".numberFormat").each(function(){ $(this).keyup(function(){ var val = $(this).val(); var res = numberWithCommas(numberWithUncommas(val)); $(this).val(res); }); }); function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function numberWithUncommas(x) { return x.toString().replace(/[^\d]+/g, ''); }
'JAVASCRIPT' 카테고리의 다른 글
스크롤시작 종료 (0) 2020.06.11 자바스크립트 많이 쓰일 함수들 (0) 2020.06.11 javascript parameter defulte 지정 (0) 2020.06.09 javascript 배열 담기 (0) 2020.06.09 javascript sprintf 02d (0) 2020.06.01