이 .js 해석좀 해주세요..
본문
$(document).ready(function() {
$('.member_sale tr').each(function() {
var aNodes = $(this).find('td');
var iPer = Number($(aNodes[1]).text().replace('%', ''));
var iSalePrice = product_price - (product_price * (iPer/100));
$(aNodes[2]).html(addCommas(iSalePrice)+'원');
});
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;
}
});
위와 같은 .js 가 있는데요..
이것때문인지 제대로 안나와서요.
쇼핑몰에 등급별가격 수치를 매기려는데 이게 가로 방향인것 같더라구요
예)
일반회원 - 0% - 10만원
우수회원 - 5% - 9만5천원
이런식인것 같은데 이것을
일반회원 우수회원
0% 5%
10만원 9만5천원
이런식으로 바꾸고 싶거든요 table을요.. 근데 안되네요..
답변 2
$(document).ready(function() {
var iPer = new Array();
var iSalePrice = new Array();
var aNodes;
$('.member_sale tr').each(function(index, item) {
var aNodes = $(item).find('td');
if(index == 1) {
for(var i=0; i<2; i++) {
iPer[i] = Number($(aNodes[i]).text().replace('%', ''));
iSalePrice[i] = product_price - (product_price * (iPer[i]/100));
}
} else if(index == 2) {
for(i=0; i<2; i++)
$(aNodes[i]).html(iSalePrice[i].toLocaleString().split('.')[0] + '원');
}
});
});
일반회원 - 0% - 10만원
우수회원 - 5% - 9만5천원
이렇게 출력되는 부분의 소스를 좀 볼수 잇을까요?
자바상에서 테이블에대한 언급이 잇긴 한데요.
자바를 건드리지 않더라도 출력되는부분에서도 원하시는 출력방향으로도 할수 잇을거 같긴 한데요.
답변을 작성하시기 전에 로그인 해주세요.