Home > Blockchain >  How to highlight text on input focus?
How to highlight text on input focus?

Time:07-02

When user clicks on input type text I want the text inside to be highlighted. I already tried on focus event and select(). It does not work. In addition I am using react.

CodePudding user response:

'

input:focus, textarea:focus{
background-color: #dcdcdc;
}
 <label>TEST</label>
 <p><input type="text" size="40"></p>

Test

input:focus, textarea:focus { background-color: blue; }'`enter code here`

CodePudding user response:

I used onFocus and it works just fine:

<input type="text" onFocus={e => e.target.select()}/>
  • Related