简体   繁体   中英

removing pseudo element ::after using jQuery

I want to know is there a way to remove the pseudo ::after. I cant show in code but I have image to explain.

图片1

When selecting a checkbox from ::before a ::after will be added now What I want is when selecting another checkbox the other checkbox will lose ::after and will be back to ::before

图像2

What I tried is

$('.ckbox label').not(this).removeAttr('::after');

But it is not removing the ::after I can say that it is not removing because the style is still there

You can't target pseudo elements this way. However you could add a class that sets the content to "none", or add a class and add the pseudo element that way, then just remove the class when you no longer want it.

.added-class:after {
  content:none
}

$('.ckbox label').addClass('added-class');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM