Hello.
Tell me please, is there a selector in jQuery to appeal to the elements with the pseudolass “After”?
or how can you contact this element to change the CSS property?
Answer 1, Authority 100%
You cannot directly address the pseudo-element, but you can change its properties by adding one or another CSS class to the main element:
HTML:
& lt; div id = "pnltest" & gt; & lt; / div & gt;
css
# pnltest
{
width: 50px; Height: 50px;
Background-Color: Black
}
#pnltest: after.
{
width: 25px;
Height: 25px;
Background-Color: Green;
Display: Block;
Content: '';
}
# PNLTEST.RED: After
{
background-color: red;
}
JS
$ ('# PNLTEST'). Hover (Function () {
$ (this) .addclass ('Red')
}, Function () {
$ (this) .RemoveClass ('Red')
});
Demo: http://jsfiddle.net/rgwrq/
Answer 2, Authority 88%
Maybe I’m wrong, but you can only get information:
var el = document.getelementbyid ('My-Elem');
var pseudostyle = window.getcomputedStyle (EL, ': AfterTe');
But you can only change via CSS, adding the desired class, or generate the “Flap” rule.
Answer 3
can be done via variable.
. Blk {
Display: INLINE-BLOCK;
Position: relative;
width: 200px; Height: 32px;
Border: 1px Solid #CCCCCC;
--Inside-Color: # 003366;
}
.blk :: after {
Content: '';
Display: Block;
Position: Absolute;
width: 24px; Height: 24px;
z-index: +2;
Border: 0px;
Border-Radius: 50%;
Right: 8px; Top: Calc (50% - 12px);
Background-color: var (- Inside-color);
}
then the main element has the CSS property of the - Inside-Color
, and the pseudo-element uses it.