-1

So I have a website, and I have a text area. The background is white and the text is black. How do I make the background color and color change when it is being typed into?

2 Answers2

1

Simply use :focus pseudo code

textarea:focus {
  background: red;
  color: white;
}
<textarea></textarea>
Gerard
  • 15,418
  • 5
  • 30
  • 52
  • Thanks. I woud just like to ask another quick question: how can I change the properties of a textarea placeholder –  Oct 25 '18 at 11:53
  • @JefferyJohnson https://stackoverflow.com/questions/43793639/change-placeholder-text-color-of-textarea – Gerard Oct 25 '18 at 11:55
0
<textarea rows="4" cols="50" id= "textId">
    My text
</textarea>

<div id="colorChange">My DIV</div>

<script type="text/javascript">
    var textAr = document.getElementById("textId");
    var colorDiv = document.getElementById("colorChange");

    function changeColor(){
        colorDiv.style.color = "blue";
    }

    textAr.addEventListener('keyup',changeColor);
</script>