How to clear text field on focus of text field

前端 未结 9 2001
悲&欢浪女
悲&欢浪女 2020-12-29 12:15

I want to clear the text field when the user clicks on that

9条回答
  •  悲哀的现实
    2020-12-29 12:49

    Unless you are doing something specific where you only want to clear onclick, I would suggest (as others have noted) to use the onfocus actions instead. This way if someone is using tab to navigate it will also clear the default text.

    You can also use onblur to check if it's empty to bring it back:

     
    

提交回复
热议问题