Skip to content
Advertisement

hide the content of the page if the user is not logged in

I am trying to hide the contents of the page if the user is not logged in, everything is now hidden except the nav. It doesn’t apply the css code that I used. enter image description here

JavaScript

as you can see in the code I have added .dipsplay-custom: none; if the user session is not set so in every parent I added display-custom the thing is the rest is displaying none, but not the nav. as you can see in the code as well I also tried displaying nav to none.

Advertisement

Answer

How about not printing the elements instead? Hiding the elements but still having them in the DOM makes it still available just by making the display: block.

Try wrapping the elements and only show them when the session is set, for example:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement