I'm trying to develop some script which toggles the display property of the css linked to my HTML document. This is in order to show/hide the navbar in the document. But when I run this script, the console shows [object HTMLDivElement] for the document.getElementById which is really confusing.
I don't think this is that of a big deal, but my head is kinda cloudy now...
function navbarCollapse() {
var navbarCollapsable = document.getElementById('nav-collapsable');
var navbarCollapsableVisibility = navbarCollapsable.style.display;
var invisible = "none";
if (navbarCollapsableVisibility !== invisible) {
navbarCollapsableVisibility = invisible;
} else {
navbarCollapsableVisibility = "block";
};
}
navbarCollapsableVisibilityor else you're assigning primitives, not references and nothing will happen.