-1

I have the following HTML:

I cannot apply any JavaScript, but I can edit the CSS. I can edit the HTML of the only

<div>
  <div>
    <span class="something">Styled content</span>
  </div>
  <div>
    Unstyled content
  </div>
</div>

I need to style (specifically, display:none;) the unstyled content as well.

I don't mind if I style the whole containing div or just the divs with content.

Is this possible?

  • You can refer this https://stackoverflow.com/questions/2326499/apply-css-styles-to-an-element-depending-on-its-child-elements – mahip_j Sep 26 '17 at 08:45
  • A parent selector would work, but I wondered if there was some way to style a div which comes after the parent of a style. Perhaps (div>.something)+div I know that wouldn't work, but perhaps something similar? – Ælim Jhang Sep 26 '17 at 10:05

1 Answers1

0

It's not possible in simply css you can read the answers here: Is there a CSS parent selector?

You can do it in jquery though:

$(".something").parent().css("display","none");

or with javascript:

document.getElementsByClassName("something")[0].parentNode.style.display= "none";
user5014677
  • 694
  • 6
  • 22