19
Views
1
Comments
Javascript Hide Button
Question

Hi OS community,


I'm just a beginner in Javascript. I'm making a calendar with buttons (Today, Yesterday, and Tomorrow)

I'm planning to have an input parameter like ShowToday (Boolean), ShowTomorrow (Boolean), and ShowYesterday(Boolean) to have an option if I want to show the buttons either Yesterday, today , tomorrow or all of them. 

This is the script 

Rank: #514

Hi Jeriel,

Am I correct in thinking that you want to hide the buttons according to input provided?

In that case I would suggest giving them a class 'hidden' whenever the input is false.

Hidden in this case would be defined as " button .hidden { display:none} ".

In this case you won't be needing to run javascript actions everytime the screen is redrawn.

It will also make it easier to toggle between hidden and not hidden.

Negative part however is that the buttons are still in the DOM only not visible to the users, which is enough for most purposes, since this is not really a security issue.

If you really want them gone though have a look at the remove node:

https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove


Kind regards,

Alexander