Based on the value of a boolean, I am looking to control the visibility of specific tabs in my sidebar when the page loads.
var someVar = true;
function show_ifTrue() {
if (Boolean(someVar) == true) {
document.getElementById('x').style.display = 'block';
console.log("I CHANGED IT");
}
else {
document.getElementById('x').style.background = 'red';
}
}
.sidebar {
position: fixed;
overflow-y: scroll;
top: 0;
bottom: 0;
float: left;
display: inline-block;
z-index: 50;
}
#tab {
display: block;
}
#x {
display: none;
}
<div class="sidebar">
<a href="#" id="tab"> Cats </a>
<a href="#" id="x" onpageshow="show_ifTrue();"> Dogs</a>
</div>
I have exhausted various methods like adjusting the CSS for .sidebar a{...}
and assigning individual display properties to each tab, using !important, modifying in JS via style.cssText or setting attribute, yet still struggling to update the display as desired.