0

I can able to get the value like this:

const childStyle = window.getComputedStyle(child, '::before');
const left = childStyle.getPropertyValue('left');

but while I try to alter like this:

  const childStyle = window.getComputedStyle(child, '::before');
  const left = childStyle.getPropertyValue('left');
  childStyle.setProperty('left', '0'); //setting not works
  console.log('childStyle', left);

getting an error as:

ERROR DOMException: Failed to execute 'setProperty' on 'CSSStyleDeclaration': These styles are computed, and therefore the 'left' property is read-only

what is the correct way to alter the value of left here? please help me.

user2024080
  • 1
  • 14
  • 56
  • 96

0 Answers0