1
아래 코드를 실행하는보다 직관적 인 방법을 찾고 있습니다. (이는 또한 내 목적에 불완전하므로)배열을 반복하고 항목을 html 요소와 일치 시키십시오.
for (j = 0; j<items.length; j++) {
var indivItem = items[j];
if (indivItem.category == 1) {
$('.indiv_category[idnumber="1"]').append('<ul class="left_side_item"><li>'+indivItem.title+'</li></ul>');
}
else if (indivItem.category == 2) {
$('.indiv_category[idnumber="2"]').append('<ul class="left_side_item"><li>'+indivItem.title+'</li></ul>');
}
}
는 기본적으로 나는 다음 if (indivItem.category > 0)
을 확인 일치 idnumber
속성이있는 요소를 찾아하고 필요한 정보를 추가 라인 3이 필요합니다.
사용할 수있는 길이가 .indiv_category
인 경우이 작업을 계속해야합니다.
기본적으로 'items'array
의 모든 항목이 동일한 id 번호가있는 배열의 항목과 일치하는 'idnumber'속성과 일치하는 모든 요소와 일치합니다.