Hello. Need to change text color. I have a select field with certain colors. For example,

 <select class="colorse"> <option style="background:#ffffff;" value="0">Белый</option> <option style="background:#000000; color: #fff;" value="1">Черный</option> </select> 

I understand that without JS there is not enough. Help me please. The color needs to be changed in the <span></span>

  • What exactly does not work for you? - Vitali
  • I do not know how to properly arrange the string to change the color of the text. - PiT

1 answer 1

The easiest option is this, but it is unlikely to be useful in a real problem.

 body { background-color: red; } 
 <select class="colorse" onchange="getElementById('color-me').style.color = this.value;"> <option style="background:#ffffff;" value="white">Белый</option> <option style="background:#000000; color: #fff;" value="black">Черный</option> </select> <span id="color-me">текст текст текст</span> 

  • I need to bring this to span - PiT