Reputation: 7417
Here is my code: http://jsfiddle.net/yvonnezoe/MKfLU/9/
i would like to know what are the values stored in my array so that it is easier for me to monitor what has been pushed in and splice out from the array. i have tried different method such as using toString()
,
$.each(rowArray, function(index, value){
newHTML.push('<span>'+value+'</span>');
});
$("#test").html(newHTML.join(" , "));
and so on... and it always give me "[object, Object]". Why so?
Upvotes: 0
Views: 81
Reputation: 3404
A row in your array is a set of 2 objects. You should display their values like that:
for(i=0;i<existingRows.length;i++){
$('#test').html(existingRows[i].type + ' ' + existingRows[i].number +'<br>');
}
EDIT:
If you want to info about all rows correctly, you should use append
method, because using html
replaces current HTML of the element - append
adds content at the end of what there actually is.
$('#test').html(''); //clear current content
for(i=0;i<existingRows.length;i++){
$('#test').append(existingRows[i].type + ' ' + existingRows[i].number +'<br>');
}
Upvotes: 2
Reputation: 4185
Because value
is an object.
Use newHTML.push('<span>'+JSON.stringify(value)+'</span>');
Upvotes: 1