728x90
fetch('/api/v1/book/'+id).then(response => {
console.log('response-opinion', response);
if (response.ok) {
return response.json();
}
}).then(json => {
console.log(json, "json");
let html = '';
if (!json.length) {
html = '<td colspan="5">등록된 책이 없습니다.</td>';
} else {
json.forEach((obj, idx) => {
console.log(obj, "obj");
html += `
<td style="text-align: center;"><span class="event-td-font">${json.length - idx}</span></td>
`;
})
}
});
에서
# 내림차순
${json.length - idx}
# 오름차순
${idx + 1}
'개발 > javascript & jquery' 카테고리의 다른 글
[JavaScript] $(function(){})이란? (0) | 2023.01.02 |
---|---|
thymeleaf에서 자바스크립트 인라인을 사용할 때 // 백단 부르기 (0) | 2022.11.10 |
ev.preventDefault() (0) | 2022.10.20 |
[Restful][ajax]xhr 문법 한방 정리(new XMLHttpRequest();) (0) | 2022.10.19 |
일정 시간 후 반복 멈추기 (0) | 2022.10.18 |