-1

The span elements in this picture are from the mdn docs on how to hide an element using css only. It works as expected. Clicking showMe/hideMe does whats expected.

How come when I try to do the same when my radio element is checked, nothing happens? Here is the relevant code:

   <!-- html -->
    <div>
      <input class="firstClass" type="radio" id="firstId">
      <label for="firstId">Yes</label>
    </div>
    <div class="expandable">
      <label for="secondId">Type of disability</label>
      <input type="text" id="secondId">
    </div>


    /* css */
    .expandable {
      display: none;
    }
    
    .firstClass:checked ~ .expandable {
      display: block;
    }

im stuck

Many thanks.

hulahoops
  • 17
  • 3

1 Answers1

0

 .expandable {
      display: block;
    }
    
    .firstClass:checked ~ .expandable {
      display: none;
    }
 <input class="firstClass" type="checkbox" id="firstId">
      <label for="firstId">Yes</label>
   
    <div class="expandable">
      <label for="secondId">Type of disability</label>
      <input type="text" id="secondId">
    </div>
نور
  • 1,023
  • 2
  • 12
  • 23