Monday 25 April 2016

how do I hide an element in javascript if localstorage variable is true

I'm trying to hide a video when the page loads and keep the video shown after any link is pressed




this is my current code



var videoplayer = document.getElementById("videoplayerlayer");
var links = document.getElementsByTagName("a");

if(localStorage !== 'undefined')
{
console.log("localStorage exists")

if(localStorage["vv"] == false)

{
videoplayer.style.display = "none";
localStorage["vv"] = false;
}
else
{
for( i=0; i {
links[i].onclick = function()
{

localStorage["vv"] = true;
videoplayer.style.display = "block";
console.log(localStorage["vv"]);
}
}
}
}
else
{
localStorage["vv"] == false;

}

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...