Reputation: 134
Is it possible to make jQuery functions (addClass
and removeClass
) affect :after
and :before
elements in CSS?
.accordion-heading > a:before {
background: url(../images/menuleftarrow.png) 98% center no-repeat;
}
.accordion-heading .accordion-toggle > a:after {
background: url(../images/menudownarrow.png) 98% center no-repeat;
}
Upvotes: 0
Views: 144
Reputation: 337560
It's not directly possible because pseudo elements such as :before
and :after
do not exist in the DOM.
The workaround is to add or remove the class on the parent element and then use that to key changes in your CSS, something like this:
$('.accordion-toggle a').addClass('foo');
.accordion-heading .accordion-toggle > a.foo:after {
background: none; /* hide the background */
}
Upvotes: 3