Is it possible to select a CSS class with JS which is registered only in its file, not exist in DOM?
var elem = document.getElementsByClassName('class2')[0],
getStyle = window.getComputedStyle(elem),
value = getStyle.getPropertyValue('top');
console.log(value);
// Can't get the value of class2 because it doesn't exist in DOM.
.class1 {
top: 10px;
}
.class2 {
top: 20px;
}
<div class="class1">
top
</div>
Like this example, There's no problem to select the .class1 because it's exist in DOM within an element.
But I want to access the .class2 which doesn't exist inside of DOM.
Are there any ways to do this?