I want to start of by saying i have read this thread Uncaught Typeerror: cannot read property 'innerHTML' of null but it has not helped me at all, and I'm really scratching my head.
I saved my data in localstorage, where I want to get the item, and if it's not there, I append a 'No movie' string instead to my html file.
This is my HTML file:
<div class="container-fluid" id="userinfo">
<p><strong>Användare</strong></p>
<p> Philip </p>
<p><strong>Favoritfilm</strong></p>
<p id="getFavMovie"> </p>
</div>
This is my JS file:
var mymovie = localStorage.getItem("favmovie");
if(mymovie == null){
document.getElementById("getFavMovie").innerHTML == 'No movie'
}
else{
document.getElementById("getFavMovie").innerHTML = localStorage.getItem("favmovie");
}
As you can see, I have declared the id getFavMovie
so I don't understand the issue of this at all.
Would appreciate some help here.