I tried to find an answer to this, but there are too many variables at play, so I hope some of you could explain to me what is happening here. I have a basic HTML page with a div which has "issuesList" id.
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="foo();">
<div id="issuesList"></div>
<script src="main.js"></script>
</body>
</html>
This is my main.js:
function foo(){
//var issues = JSON.parse(localStorge.getItem('issues'));
var issuesList = document.getElementById('issuesList');
document.getElementById('issuesList').setAttribute("style", "color:red;")
issuesList.setAttribute("style", "color:red;");
issuesList.innerHTML = 'XYZ';
}
The localStorage is empty, so it has no 'issues' object.
If I leave the commented line commented out, the issuesList DOM element will show XYZ written in red. If I uncomment it, then issuesList element remains empty. I don't understand why this is happening.
Also, if I add 'issues' to localStorage, and call again foo() method, still nothing is shown in the 'issuesList' element.
Thank you
undefined, that will do.