Assume your CSS looks like:
.element:before {
content: 'NEW';
color: rgb(255, 0, 0);
}
To retrieve the color property of the .element:before, you could use the following JavaScript:
To retrieve the color property of the .element:before, you could use the following JavaScript:
var color = window
.getComputedStyle(document.querySelector('.element'), ':before')
.getPropertyValue('color')
Passing the pseudo-element as the second argument to window.getComputedStyle allows access to said pseudo-element styles
Passing the pseudo-element as the second argument to window.getComputedStyle allows access to said pseudo-element styles
Комментариев нет:
Отправить комментарий