How to show/hide input value on focus?

后端 未结 7 1944
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 12:44

I see this all over the web, but was wondering if anyone has the JavaScript code for the EASIEST way to show input value on blur, but hide in on focus.

相关标签:
7条回答
  • 2021-02-06 13:20

    The simplest approach I know of is the following:

    <input 
        name="tb" 
        type="text" 
        value="some text"
        onblur="if (this.value=='') this.value = 'some text'" 
        onfocus="if (this.value=='some text') this.value = ''"  /> 
    
    0 讨论(0)
提交回复
热议问题