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

3
  • 2
    jQuery cannot access pseudo elements as they aren't part of the DOM, so what you're trying to do isn't possible Commented Jan 25, 2017 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 } Commented Jan 25, 2017 at 17:34
  • You are right. I just realized that. I just read a similar article. Commented Jan 26, 2017 at 20:06

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.