0

I'm editing a CSS class that alters hyperlink (a) elements. But I want those elements which contain images (img) to be ignored on that class.

This is an example of the current structure of my HTML:

    <div class="myDiv">
    <a href="foo">  <!-- no class -->
    <img src="foo">  <!-- no class -->
    </a>
    <p></p>
    <a href="bar">TEXT</a>  <!-- no class -->
    </div>

I can't change the HTML structure and I can't guarantee that the second hyperlink element will be always the second.

I want to alter only the one who have just plain text.

How can I do that?

legoscia
  • 37,068
  • 22
  • 103
  • 148
digofreitas
  • 141
  • 6
  • 1
    Your comment syntax is incorrect (you can see as much in the fact that the site isn't highlighting your HTML correctly). – BoltClock Jul 30 '14 at 13:38
  • Look at something like jQuery's `:has()` (http://api.jquery.com/has/). You can't select an ancestor by descendants with just CSS (yet). – Casey Falk Jul 30 '14 at 13:40
  • or jQUery .not or :not , and what do you mean you can't change the HTML structure , ofcourse you can – Scott Selby Jul 30 '14 at 13:41
  • @ScottSelby, not if he is downloading the HTML from an external widget/etc.. Not *easily* that is. – Casey Falk Jul 30 '14 at 13:42
  • 1
    you can read it as it is being downloaded , before it is appended to the DOM , that is if you are that against jQUery – Scott Selby Jul 30 '14 at 13:42
  • I don't want to use jQuery. And it isn't a duplicate question, how do it change that? The other question doesn't answer mine. – digofreitas Jul 30 '14 at 13:57

0 Answers0