How to show/hide input value on focus?

后端 未结 7 1985
隐瞒了意图╮
隐瞒了意图╮ 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:19

    Since this still comes up on google, I'd like to point out that with HTML 5 you can use the placeholder attribute with an input to achieve this in one piece of html.

    
    

    Placeholder is now standard across modern browsers, so this really would be the preferred method.

提交回复
热议问题