2

Hi have a DOM like this and need to select all a-elements except for those that are descendants of the div.hidden section.

<body>
<div>
    Some text <a href="mailto:alex@domain.com">Email Alex</a> Some more text
    <br/>
    <span>
        Some text <a href="mailto:frank@domain.com">Email Frank</a> Some more text
    </span>
    <hr/>
    <div class="hidden">
        Some text <a href="mailto:rachel@domain.com">Email Rachel</a> Some more text
        <div>
            Some text <a href="mailto:doris@domain.com">Email Doris</a> Some more text
            <p>
                Some text <a href="mailto:molly@domain.com">Email Molly</a> Some more text
            </p>
        </div>
    </div>
    <hr/>
    <div>
        Some text <a href="mailto:paul@domain.com">Email Paul</a> Some more text
    </div>
</div>
</body>

So all the a-elements within the horizontal lines would be excluded. How can I do that? Using jQuery is not an option unfortunately.

Thanks Alex

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356

1 Answers1

3

One way to do that is to make a rule for all <a> elements and then override with one that reverses the rule for the ones that are in the div.hidden, i.e.

a {
    prop: special-value;
}
div.hidden a {
    prop: not-special-value;
}
fred02138
  • 3,323
  • 1
  • 14
  • 17