79723695

Date: 2025-08-02 22:48:45
Score: 1.5
Natty:
Report link

Perhaps you can do this with :targetmdn instead of with javascript?

section:not(:target) :not(:first-child) { display: none; }
<section id="parent1">
  <h1><a href="#parent1">Parent1</a></h1>
  <ul class="child">
    <li>
      Some content
    </li>
  </ul>
</section>
<section id="parent2">
  <h1><a href="#parent2">Parent2</a></h1>
  <ul class="child">
    <li>
      Some content
    </li>
  </ul>
</section>
<section id="parent3">
  <h1><a href="#parent3">Parent3</a></h1>
  <ul class="child">
    <li>
      Some content
    </li>
  </ul>
</section>

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: imme