Show/Hide "a div" by clicking on radio button

Asked

Viewed 289 times

0

How do I, when dialing a radio buttom, release a content from a div? Type this example only using radio buttom! Thank you

    <label>Mostrar termos:</label> <input type="checkbox" id="termos" />
<div id="termoTexto">
    Seus termos estarão aqui
</div>


    input[type=checkbox]:checked ~ #termoTexto{
    display: block;
}
#termoTexto {
    display:none;
}

1 answer

1


Just use the id radio as selector. But radio behaves differently than checkbox, which can be checked/unchecked.

#termos:checked ~ #termoTexto{
    display: block;
}
#termoTexto {
    display:none;
}
<label>Mostrar termos:</label> <input type="radio" id="termos" />
<div id="termoTexto">
    Seus termos estarão aqui
</div>


Since you tagged it in question, has a solution with Javascript also:

document.getElementById("termos").onclick = function(){
   document.getElementById("termoTexto").style.display = "block";
}
#termoTexto {
    display:none;
}
<label>Mostrar termos:</label> <input type="radio" id="termos" />
<div id="termoTexto">
    Seus termos estarão aqui
</div>

Just change the display element by clicking on the radio.

  • <div class="panel-body " id="formadepagamento"> <div class="Row"> <div class="col-Md-6 text-left H3"> Payment form </div> </div> <br> </div>

  • he did not display this div

  • The answer is based on what is in the question.

  • I put a shape using JS.

  • Thanks, it worked out

Browser other questions tagged

You are not signed in. Login or sign up in order to post.