I am trying to store the specSize
, specTitle
and specURL
which are in table to session storage, will be using it in different page. On load I see the session data, but if i try to add the items to session storage by clicking the button it clears the existing items and put the new ones instead of appending the onclick items to existing ones.
Here is my code:
window.specSize;
window.specTitle;
window.specURL;
function specInfo (sSize, sTitle, sURL){
this.specSize = sSize;
this.specTitle = sTitle;
this.specURL = sURL;
}
var specArr = []
$('.flag-bookmarks a').on("click",function(e){
e.preventDefault();
specSize = $(this).parent().parent().parent().find("td:first").html();
specTitle = $(this).parent().parent().parent().find("td:nth-child(2) a").html();
specURL=$(this).parent().parent().parent().find("td:nth-child(2) a").attr("href");
specArr.push(new specInfo(specSize,specTitle,specURL))
sessionStorage.setItem('storedInfo', JSON.stringify(specArr));
});
storedValue = JSON.parse(sessionStorage.getItem('storedInfo'));
alert(storedValue);