Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Selecting a container DIV from a known link inside

$
0
0

I am trying to work out how to select a container by a link contained within it. It looks something like this:

<div>
  <p>Some text here</p>
  <a href="www.test.com">My Link</a>
</div>

I know the value of "My link". However, the div has no ID or class and is not contained within anything except the body.

How could I use javascript to select the div element so I can manipulate it? I've found ways to select the link using the DOM but not the outer div. There are many divs on the page, so I cannot just select div.

Your help is appreciated!


Viewing all articles
Browse latest Browse all 138163

Trending Articles