일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- JSON
- vue Carousel
- 구멍가게코딩단
- vue.js
- query
- vscode tutorial
- 정보처리산업기사
- jsp
- spring
- insertAll
- MariaDB
- mybatis
- 오라클
- 마스킹
- checkbox
- mysql
- JAXBContext
- java
- egov
- bulkinsert
- Ajax
- 기출문제
- jdbc
- INSERT
- JQuery
- github
- NoSQL
- Tomcat
- swipe 배너
- 부스트코스
Archives
- Today
- Total
개발새발
[java script] 화폐단위 콤마 함수 본문
728x90
반응형
1
2
3
4
|
function AddComma(num){
var regexp = /\B(?=(\d{3})+(?!\d))/g;
return num.toString().replace(regexp, ',');
}
|
<example>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
function AddComma(num){
var regexp = /\B(?=(\d{3})+(?!\d))/g;
return num.toString().replace(regexp, ',');
}
for(var i = 0; i <obj['data'].length; i++){
var priceClose = AddComma(obj.data[i].priceClose);
var priceAvg5 = AddComma(obj.data[i].priceAvg5);
var priceAvg10 = AddComma(obj.data[i].priceAvg10);
var priceAvg20 = AddComma(obj.data[i].priceAvg20);
var priceAvg60 = AddComma(obj.data[i].priceAvg60);
var volume = AddComma(obj.data[i].volume);
var volumeAvg5 = AddComma(obj.data[i].volumeAvg5);
var volumeAvg20 = AddComma(obj.data[i].volumeAvg20);
var volumeAvg60 = AddComma(obj.data[i].volumeAvg60);
html += '<tr>';
html += '<td class="listtd">'+obj.data[i].dealDate+'</td>';
html += '<td class="listtd">'+priceClose+'</td>';
html += '<td class="listtd">'+priceAvg5+'</td>';
html += '<td class="listtd">'+priceAvg10+'</td>';
html += '<td class="listtd">'+priceAvg20+'</td>';
html += '<td class="listtd">'+priceAvg60+'</td>';
html += '<td class="listtd">'+volume+'</td>';
html += '<td class="listtd">'+volumeAvg5+'</td>';
html += '<td class="listtd">'+volumeAvg20+'</td>';
html += '<td class="listtd">'+volumeAvg60+'</td>';
html += '</tr>';
}
|
728x90
반응형
Comments