javascript - removing pseudo element ::after using jQuery - Stack Overflow

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

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

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

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

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

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

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

Share Improve this question edited Nov 28, 2017 at 16:27 Shiladitya 12.2k17 gold badges28 silver badges42 bronze badges asked Nov 28, 2017 at 16:17 MartinMartin 3755 gold badges7 silver badges25 bronze badges 9
  • Look at this question – Philipp Maurer Commented Nov 28, 2017 at 16:21
  • 2 Possible duplicate of Removing an element added by ::before pseudo selector – Daniel Beck Commented Nov 28, 2017 at 16:21
  • @DanielBeck i tried it it is not working because there is still the ::after so I rreally need to find a way to remove it.. I will try triggering the click for other checkbox maybe it work. is there a drawback if i trigger many checkbox at once? – Martin Commented Nov 28, 2017 at 16:31
  • I do not understand what you're saying in that ment at all. If you want to remove content added in a ::before or ::after pseudoclass, you need to do that in CSS (by setting the pseudoclass content to an empty string). You can't clear it with "removeAttr()" because it is not an attribute, it's a pseudoclass. – Daniel Beck Commented Nov 28, 2017 at 16:34
  • 2 But, yes, if the reason you were trying to do this was to enforce that only one is checked at a time, you would definitely want to be using a radio button for that instead. – Daniel Beck Commented Nov 29, 2017 at 2:22
 |  Show 4 more ments

1 Answer 1

Reset to default 4

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744238327a4564580.html

相关推荐

  • javascript - removing pseudo element ::after using jQuery - Stack Overflow

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

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信