I have a local storage key name "A" which contains an array of table rows. When I alert the whole array it shows [object HTMLTableRowElement],[object HTMLTableRowElement]
But when I loop over the array I am not getting the object in my variable, instead I get [ only.
How to properly fetch the table row objects from the array.
Here is my code :
if (localStorage.getItem("A") !== null) { var lArray = localStorage.getItem("A"); alert(lArray); // alerts [object HTMLTableRowElement],[object HTMLTableRowElement] for(var i=0 ; i < lArray.length ; i++) { alert(lArray[i]); // alerts [ } } And here is how I am putting the table rows in my local storage
var favA = []; function addRow() { var tableRow = document.createElement("TR"); var trID = "Tr"; tableRow.setAttribute("id", trID); favA.push(tableRow); if (typeof(Storage) !== "undefined") { localStorage.setItem("A", favA); }