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);
}
}
I want to pass dynamic id argument this.unorderListLi[l].addEventListener('click', function() { ajaxJsonFetchPost(this.persons[person]['id']); }, false);
instead of manual id (965). but it is out of the loop.
Can anyone tell me what is the actual process?
Thanks.