javascript – How to get modified color of input's placeholder-ThrowExceptions

Exception or error:
input::placeholder {
  color: red;
}
<input type="text" placeholder="Hello world">

I am looking over an accessibility problem, and I need to identify the applied CSS style specifically color on input’s placeholder.

What I have tried

const inputEl = document.querySelector('input'),
 styles = window.getComputedStyle(inputEl, ':placeholder');
console.log(styles.getPropertyValue('color'));
input::placeholder {
  color: red;
}
<input type="text" placeholder="Hello world">

But I am getting rgb(0, 0, 0)

Help will be appreciated. Thanks in advance

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *