-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
  • 14,447
  • 5
  • 28
  • 48
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>