this.jsonFetch = function() {
for (person in this.persons) {
console.log(person, '= ', this.persons[person]['title']);
this.unorderList.innerHTML += "<li><a id='aid" + this.persons[person]['id'] + "'href='#' >" + this.persons[person]['title']['rendered'] + "</a></li>";
}
this.unorderListLi = document.getElementById("ul").getElementsByTagName("a");
for (l = 0; l <= this.unorderListLi.length; l++) {
this.unorderListLi[l].addEventListener('click', function() { ajaxJsonFetchPost(965); }, false);
}
}
수동 ID (965) 대신 동적 ID 인수 this.unorderListLi[l].addEventListener('click', function() { ajaxJsonFetchPost(this.persons[person]['id']); }, false);
을 전달하고 싶습니다. 그러나 그것은 루프에서 벗어났다. 아무도 실제 프로세스가 무엇인지 말해 줄 수 있습니까? 감사합니다. .자바 스크립트의 루프에서 인수를 전달할 수있는 방법
감사합니다 @Sushanth - 매력처럼 작동합니다. –
@ sumum 당신은 환영합니다 :) –