Say I have Radio Buttons and a Div.
<input id="one" type="radio" value="1">
<label>One</label>
<input id="two" type="radio" value="2">
<label>Two</label>
<div id="mainDiv">
<p>Hello</p>
</div>
How do I hide the div block only if radiobutton one is checked? Without using any other language and only css.
I tried to use +
and ~
. I dont know if im using it wrong but it didnt work.
You can use the
checked
property of theone
radio button together with the~
combinator:Also, you can check the example from documentation MDN Toggling elements with a hidden checkbox