Jquery - Odd Integer/string Issue
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, fou
Solution 1:
EDIT: As ZenMaster points out in the comments, as you're not using id
as a number, this is definitely not the issue.
It is quite likely that the data you are pulling out is indeed a string, you'd need to show what your JSON looked like.
If that is the case, you'll want to use the parseInt
function to tell javascript to parse the string as an integer.
var id = parseInt(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);
});
Solution 2:
First of all numeric IDs are invalid. So do not use them..
Secondly make sure the firstLevel.id
does not have trailing or leading whitespace ..
try console.log(id, id.toString().length);
and see if the length
is indeed 3
Post a Comment for "Jquery - Odd Integer/string Issue"