The one without callback function jsFiddle produces wrong outcome. The console log should show i=0 & j=0 as indicated "group[0] record[0]". because I am trying to find the dd/dt set: "Book: a book name".
I understand I need to include a callback function similar to this post. However I don't seem to understand how to insert the function correctly. Here is the one I am working on:
var arrDL = [];
$("dl").each(function(i) {
arrDL[i] = [];
$(this).children("dt").each(function(j){
function(n){
return function(){
var $this = $(this);
arrDL[n][j] = {
title: $this.text(),
description: $this.next("dd").text()
};
if($this.text() == "Book:" && $this.next("dd").text() == "another book name"){
console.log("group 0 record 0: " + n + '-' + j);
};
};
}(n);
});
});
Thanks for your help.