1

I'm wondering is there a way to access to parent:before of a element with css or jQuery or..? I should make :before of li display: none if a has TopNavActive class, in this code I should hide before if a has TopNavActive Class.

<li>::before 
    <a class="TopNavActive" href="/Cat14/14.html">
    Mobile
    </a>
</li>
Pedram
  • 15,766
  • 10
  • 44
  • 73
  • Not directly, pseudo-elements (before, after, etc) are not accessible through JavaScript, and CSS cannot select parent elements, at least not yet. – Alexander O'Mara Nov 17 '15 at 07:04
  • Possible duplicate of [How to access CSS generated content with JavaScript](http://stackoverflow.com/questions/2651739/how-to-access-css-generated-content-with-javascript) – smnbbrv Nov 17 '15 at 07:04
  • 1
    Possible duplicate of [Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery](http://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin) – Brett DeWoody Nov 17 '15 at 07:06

1 Answers1

1

I found a solution:

JS:

$('.TopNavActive').parent('li').addClass('MyTarget');

CSS:

.MyTarget::before {
    display: none!important;
}
Pedram
  • 15,766
  • 10
  • 44
  • 73