I need to check if the link (a-tag) is the only content (and not just the only child) inside the paragraph tag (p). Therefore, if the p-tag looks like this:
<p>Here we have some text inside the p-tag. Then there <a href="#">link</a>.</p>
The <a>
tag is not the only content inside the p-tag, since there is also text there.
But if the <p>
looks like this:
<p><a href="#">Nothing but a link inside this p-tag</a></p>
the only content inside the <p>
is the link.
If the <p>
tag contains only the <a>
tag, I want to add a specific class to the <a>
tag.
I used this code:
$("#MainColumn pa:only-child").addClass("singleLink");
but this code checks to see if only the a tag is the only p-tag tag, and not the only content . That's where I'm stuck right now.
tkahn source share