Get ::placeholder color using Javascript

Solution 1:

the second parameter of getComputedStyle is pseudoElt selector

so to get placeholder color of your input element:

var styles = window.getComputedStyle(inputEl, ':placeholder');
console.log(styles.getPropertyValue('color'));

Solution 2:

It's

window.getComputedStyle(inputEl, '::placeholder').getPropertyValue("color");
// note the DOUBLE colon here ----^^

Works in both Chrome and Firefox