7

I have a CSS file that specifies an :after style against a class ('view-performance')

Using jQuery (because my JS file contains the business logic), how can I remove the :after style based on the business logic?

Mike
  • 2,391
  • 6
  • 33
  • 72

2 Answers2

13

You cannot reach pseudo elements using jQuery!

But you can do it with css, and manipulate it using .addClass() / .removeClass()

Here is an example how can you remove pseudo element :after by adding css class:

Your JS:

$('.view-performance').addClass('without-after-element');

Your CSS:

.view-performance:after {
  content: 'i go after';
}
.view-performance.without-after-element:after {
  content: none;
}

You may also check this question:

stackoverflow.com/questions/17788990/access-the-css-after-selector-with-jquery

Community
  • 1
  • 1
Anton Temchenko
  • 1,440
  • 1
  • 13
  • 28
-1
$('.view-performance:after').css('display','none');
Pawan Nogariya
  • 8,330
  • 12
  • 52
  • 105