In my latest program, there is a button that displays some input popup boxes when clicked. After these boxes go away, how do I hide the button?
You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <button> is not visible, but maintains its position on the page.
To hide an element, set the style display property to “none”. document. getElementById("element").
You can set its visibility
property to hidden
.
Here is a little demonstration, where one button is used to toggle the other one:
<input type="button" id="toggler" value="Toggler" onClick="action();" /> <input type="button" id="togglee" value="Togglee" /> <script> var hidden = false; function action() { hidden = !hidden; if(hidden) { document.getElementById('togglee').style.visibility = 'hidden'; } else { document.getElementById('togglee').style.visibility = 'visible'; } } </script>
visibility=hidden
is very useful, but it will still take up space on the page. You can also use
display=none
because that will not only hide the object, but make it so that it doesn't take up space until it is displayed. (Also keep in mind that display's opposite is "block," not "visible")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With