Question: I know i can't access :before and :after selectors via jQuery by writing a code like this. Because :before / :after are not the part of the DOM.
$(document).ready(function(e){
var beforebg = $('.SomeClass:before').css('background-color');
})
Is there any way i can save the value in a variable or there isn't any way at all? I know there are methods discussed here like on this post where it says that i make another class and define :before / :after on that class and then toggle that class using jQuery. But that is not my requirement here. I need this value to be stored in a variable so to use in my script.
Update: Why i need this to be stored in a vairable?
Please refer to my this question here to know what am doing. When i am able to store this value in a variable, i'd be able to iterate over DOM using each() and then i'll be able to add a specific class to an element that has a background-color equal to the color stored in that variable (beforebg in my case).
Update: Check this css code
.service-content:after {
background: none repeat scroll 0 0 #eb2c33;
border-radius: 100%;
box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.09);
content: "";
height: 8px;
left: 274px;
margin-top: -58px;
position: absolute;
top: 50%;
width: 8px;
z-index: 3;
}
So can i store the value "background" color value ( "#eb2c33" in this case ) in the variable beforebg?