[jQuery] 금액단위 제거 표기

구글신에겐 역시 없는게 없다...

http://jsfiddle.net/praveenscience/R8JrF/1/

<table id="price">
<tr>
<td class="price_01">700,000</td>
<td>5,000</td>
<td class="price_rs"></td>
</tr>
<tr>
<td class="price_01">600,000</td>
<td>3,000</td>
<td class="price_rs"></td>
</tr>
<tr>
<td class="price_01">500,000</td>
<td>7,000</td>
<td class="price_rs"></td>
</tr>
</table>

<script type="text/javascript">
$(".price_01").each(function(){
var price_01 = $(this).html().replace(/,/g, "");
var price_02 = $(this).next().html().replace(/,/g, "");
var price = (price_01-price_02).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
var price_rs = $(this).next().next(".price_rs");

price_rs.html(price);
});
</script>


댓글

이 블로그의 인기 게시물

[iOS] body 스크롤 막기

[html] 모바일웹 작업 팁 정리중...

Swiper lazyLoading