#jobForm
의 ID를 가진 양식이 있습니다. #jobForm
에서 , 난 항상 내가 JSON 문자열에서 데이터를 읽고 있어요jquery 대상 클래스의 n 번째 인스턴스
웹 서버에서 반환 .allCharges
라는 하나의 클래스가 클래스 .jIN
에서 .jIN
와 <div>
년대의 수에는 제한이 없습니다 . charges
이라는 json 배열이 있습니다. 이 charges
인 경우 .allCharges
에 해당하는 block
이라는 필드가 있습니다. 타겟팅 및 charges.chargesDesc
내가이 일을하고있어 함께 올바른 .allCharges
을 채우려 :
<form id="jobForm">
<div class="jIN">
<div class="allCharges"></div>
</div>
<div class="jIN">
<div class="allCharges"></div>
</div>
<div class="jIN">
<div class="allCharges"></div>
</div>
</form>
var cl=json.charges.length;
for(i=0;i<=cl-1;i++){
var block=json.charges[i].block;
$("#jobForm.jIN:eq("+block+") .allCharges").append(json.charges[i].chargeDesc);
}
을하지만이 작동하지 않습니다.
[n 번째 자식 선택기] (http://api.jquery.com/nth-child-selector/) 어쩌면? – lemieuxster
선택기에 누락 된 공간이 있습니까? ID 뒤에 그리고'.jIN' 클래스 앞에 – tymeJV