0

Hello Im try to set css attribute to element, which create by pseudo-class ":after"

I'm know how to get: element = document.querySelector('.some-class'); var top = getComputedStyle(element, ':after').getPropertyValue("top") but object is returned by this method is read only

I try this:

element = document.querySelector('.some-class:after');
element.style.top = "100px"; 

but it not work...

  • You can't write inline styles directly to the pseudo element using JavaScript. However, one workaround is to use JavaScript to write styles to an inline – delinear Oct 31 '17 at 11:58
  • Related - https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin – Paulie_D Oct 31 '17 at 12:40

1 Answers1

0

:after means pseudo-element. You can't get it with JS, only CSS. So you need to try to use DOM element