0

I have the following CSS class

 .ad-panel::after {
 content: "";
 display: block;
 height: 0;
 padding: 65.86% 0 0;
 width: 100%;
}

How can I check if my .ad-panel:after class is empty? I am using the following Jquery code but it doesn't seem to work.

    jQuery(document).ready( function($) {

          if ($('.ad-panel').css('content','') {
            alert('No content!')
          }

    })

Any suggestions? I figure that the syntax is wrong somewhere. Thanks

Hemant
  • 1,961
  • 2
  • 17
  • 27
Mariton
  • 601
  • 2
  • 12
  • 28
  • 2
    jQuery cannot access pseudo elements as they aren't part of the DOM, so what you're trying to do isn't possible – Rory McCrossan Jan 25 '17 at 17:31
  • Would you be able to create a custom class that has your ::after stuff that would only have it, and use jquery's `.addClass()` or `.toggleClass()` to switch it on and off and then use `if($('.myDiv').hasClass('yourCustomClass')){ //do something }` – oompahlumpa Jan 25 '17 at 17:34
  • You are right. I just realized that. I just read a similar article. – Mariton Jan 26 '17 at 20:06

0 Answers0