I'm struggling to select an element within a nested <ul>
.
In this code snippet, my goal is to pinpoint the <a>
tag that follows the parent <li>
<ul class="wc-block-product-categories-list wc-block-product-categories-list--depth-0">
<li class="wc-block-product-categories-list-item">
<a style="" href="#"> <!-- Target this link -->
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
<ul class="wc-block-product-categories-list wc-block-product-categories-list--depth-1">
<li class="wc-block-product-categories-list-item">
<a style="" href="#">
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
</li>
<li class="wc-block-product-categories-list-item">
<a style="" href="#">
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
</li>
<li class="wc-block-product-categories-list-item">
<a style="" href="#">
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
</li>
<li class="wc-block-product-categories-list-item">
<a style="" href="#">
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
</li>
</ul>
</li>
<li class="wc-block-product-categories-list-item">
<a style="" href="#"> <!-- Target this link -->
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
<ul class="wc-block-product-categories-list wc-block-product-categories-list--depth-1">
<li class="wc-block-product-categories-list-item">
<a style="" href="#">
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
</li>
<li class="wc-block-product-categories-list-item">
<a style="" href="#">
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
</li>
<li class="wc-block-product-categories-list-item">
<a style="" href="#">
<span class="wc-block-product-categories-list-item__name">text</span>
</a>
</li>
</ul>
</li>
</ul>
I've attempted using various selectors like child selectors (>), adjacent and general sibling selectors (~ and +), pseudo-classes (:first-child) but have been unable to access that specific hyperlink.