简体   繁体   English

删除伪元素::使用jQuery之后

[英]removing pseudo element ::after using jQuery

I want to know is there a way to remove the pseudo ::after.我想知道有没有办法删除伪 ::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::before选择复选框::after我想要的是选择另一个复选框时,另一个复选框将丢失::after将返回::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但它并没有删除::after我可以说它没有删除,因为样式仍然存在

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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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