0

I have this CSS: input::placeholder {font-size: 30px}

and I trying to change input placeholder CSS in JS

var inputPlaceholder = document.querySelector("input::placeholder");
inputPlaceholder.style.fontSize = "5px";

but console returns Uncaught TypeError: Cannot read property 'style' of null.

How to to change input placeholder CSS in the right way?

1 Answers1

0

Try For This:

<input type="text" style="font-size: 30px" placeholder="Here." id="new"/>

var inputPlaceholder = document.getElementById('new');
inputPlaceholder.style.fontSize = "5px";
Kunvar Singh
  • 1,779
  • 2
  • 13
  • 21