html 질문
관련링크
본문
e_compare = - 1
let gh = 'color_blue';
let safe = '안심';
let cls_safe = 'safe';
const t_month = '05';
const t_day = '21';
TOTAL = 111
str = "<li>" + " <p>전일대비<span class=" + gh + ">" + abs_compare + "%</span></p>" + " <div class='graph'>" + " <p class='payment'>총 납부 금액<br>" + t_month + "/ " + t_day + "(기준)</p>" + " <strong class='sum'>" + addComma(obj.realTime.TOTAL) + "</strong>" + " <span class='unit'>원</span>" + " </div>" + " <span class=" + cls_safe + ">" + safe + "</span>" + " </li>" $('#goalEng').append(str);
const $br = $('<br/>')
const $span_compare = $('<span/>', {
classNmae: gh,
html: abs_compare + '%'
});
const $p_compare = $('<p/>', {
text: "전일대비"
}).append($span_compare);
let $li = $('<li/>').append($p_compare);
// div , p, strong, sapn
const $p_pay = {
className: 'payment',
text: '총 납부 금액' + $br + t_month + "/ " + t_day + "(기준)"
}
const $stong_sum = {
className: "sum",
text: addComma(obj.realTime.TOTAL)
}
const $span_uinit = {
className: "unit",
text: "원"
}
const $span_safe = {
className: cls_safe,
text: safe
}
const $div = $('div', {
className: 'graph',
}).append($p_pay).append($stong_sum).append($span_uinit);
$li.append($div)
$('#goalEng').append($li);
답변 1
str = "<li>" + " <p>전일대비<span class=" + gh + ">" + abs_compare + "%</span></p>" + " <div class='graph'>" + " <p class='payment'>총 납부 금액<br>" + t_month + "/ " + t_day + "(기준)</p>" + " <strong class='sum'>" + addComma(obj.realTime.TOTAL) + "</strong>" + " <span class='unit'>원</span>" + " </div>" + " <span class=" + cls_safe + ">" + safe + "</span>" + " </li>" $('#goalEng').append(str);
하드 코딩 된것을
하드코딩 아래에 된 부분처럼
$요소 = $('엘레멘트', {
text: '내용'
})
$("#부모").append($요소)
이렇게 표현 가능할까요?