HTML and JavaScript Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HTML and JavaScript Question

I want to have a program that has a bunch of buttons and all buttons will hide when one is pressed? How would I do this?

16th Oct 2020, 9:00 PM
Gizmo-Lang
Gizmo-Lang - avatar
2 Answers
+ 2
Hola prueba lo siguiente. En tu html pon lo siguiente: <Div id="myDIV">este es mi DIV </div> Y en un javascript lo siguiente: function myFunction() { var x = document.getElementById("myDIV"); if (x.style.display === "none") { x.style.display = "block"; } else { x.style.display = "none"; } } Recuerda enlazar el JavaScript en Html. Y prueba a darle si quieres estilos css al div, por ejemplo: #myDIV { width: 100%; padding: 50px 0;  text-align: center; background-color: lightblue; margin-top: 20px; } Esto va en el css Un saludo
16th Oct 2020, 9:42 PM
Miguel Ángel
Miguel Ángel - avatar