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
- 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
1 Answer
Reset to default 4You 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
评论列表(0条)