pstein Posted April 12, 2020 Share Posted April 12, 2020 At first an example: <div class="foobar" ....>.... <div class="....." ...>..... <div class="....." ....>.... <div class="....." ....>..... <img src="https:\\www.imgdomain.com\..." ....></img> ...</div> ....</div> ....</div> ....</div> How do I address the following elements: Find <img> with src="https:\www.imgdomain.com* and go upwards in hierarchy until a <div> element with class="foobar" ist found Same as 1. but this time the element just below <div> with class="foobar" should be referred (which could be the <img> element itself) If no <div> element with class="foobar" is found nothing should happen jQuery or Javascript can be used Link to comment Share on other sites More sharing options...
dsonesuk Posted April 12, 2020 Share Posted April 12, 2020 (edited) As the target that you ultimately will want would be class element 'foobar' would it not be better to transverse down to img from that class name . var x = document.querySelectorAll(".foobar img[src='https:\www.imgdomain.com']"); Edited April 12, 2020 by dsonesuk Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now