ScreenSteps

Advanced Channel Selectors

Updated on

Adjacent Content

<div class="bob">
  <label>Wally</label>
  <span>Mary</span>
</div>
<div class="bob">
  <label>Tom</label>
  <span>Mary</span>
</div>
Click to copy

Sometimes you might have a page where you need to match on two elements that are next to each other. See the code below.

This selector would target the 2nd div.

.bob:has(label:contains("Tom") + span:contains("Mary"))
Click to copy

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Still Need Help? Contact Us