I''ve been working on this all day long and haven't get it yet. I have this code to load and display some JSON data:
var id = firstLevel.id;
$.each(thirdLevel, function(index4, fourthLevel) {
$('#'+id+' tr:nth-child('+currentRow+')').append("<td>M "+fourthLevel.male+"</td>");
$('#'+id+' tr:nth-child('+currentRow+')').append("<td>H "+fourthLevel.herm+"</td>");
currentRow++;
console.log(id);
});
It's supposed to insert new columns to a row using the id of the table (I have a lot of tables with different ids each one) but the "id" variable doesn't seem to be working right, and I'm printing it to console and it has the right value (421 in the first iteration)
Now, if I do this:
var id = 421;
$.each(thirdLevel, function(index4, fourthLevel) {
$('#'+id+' tr:nth-child('+currentRow+')').append("<td>M "+fourthLevel.male+"</td>");
$('#'+id+' tr:nth-child('+currentRow+')').append("<td>H "+fourthLevel.herm+"</td>");
currentRow++;
console.log(id);
});
It will work, and insert all the new columns on the table with id 421...
So, is there something wrong with my code? Thank you very much!