Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to make my bmi calculator appear and disappear on click?

so i’ve been browsing trying to get the answer but i dont have found any easy way to do it, if there is any, do you guys know any way that i can do it?

HTML:

<main id="main">
        <div class="container">
          <div class="title"> Calculadora - IMC </div>
          <div class="input">
              <label>Nome:</label>
              <input type="text" id='nome'>
          </div>
          <div class="input">
              <label>Altura:</label>
              <input type="number" id='altura'>
          </div>
          <div class="input">
              <label>Peso:</label>
              <input type="number" id='peso'>
          </div>
          <button id='calcular'>Calcular</button>
  
          <div class="result" id='resultado'></div>
        </div>
      </main>

JavaScript:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function desaparecer(){

    document.getElementById("main").style.display = "none";{
    }

CSS:

>Solution :

You can toggle a class that hides the container.

document.querySelector('#toggleVis').addEventListener('click', e => {
  document.querySelector('.container').classList.toggle('hide');
});
.hide {
  display: none;
}
<main id="main">
  <div class="container">
    <div class="title"> Calculadora - IMC </div>
    <div class="input">
      <label>Nome:</label>
      <input type="text" id='nome'>
    </div>
    <div class="input">
      <label>Altura:</label>
      <input type="number" id='altura'>
    </div>
    <div class="input">
      <label>Peso:</label>
      <input type="number" id='peso'>
    </div>
    <button id='calcular'>Calcular</button>

    <div class="result" id='resultado'></div>
  </div>
  <button id="toggleVis">Hide/Show</button>
</main>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading