Home>Article>Web Front-end> How to set the text box color to change when input in javascript

How to set the text box color to change when input in javascript

醉折花枝作酒筹
醉折花枝作酒筹 Original
2021-06-09 16:24:02 6416browse

In JavaScript, you can use the onfocus event to set the text box to change color when input. You only need to bind the onfocus event to the element, and then use "object.style.background="color value"". The onfocus event occurs when an object gains focus and is typically used in forms.

How to set the text box color to change when input in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Dynamicly set the text box color:

主要是利用javascript中的触发事件onfocus