How to create a label inside an <input> element?

后端 未结 13 858
悲哀的现实
悲哀的现实 2021-01-29 22:54

I would like to insert a descriptive text inside an input element that disappers when the user click on it.

I know it is a very common trick, but I do not know how to do

13条回答
  •  情书的邮戳
    2021-01-29 23:26

    I've put together solutions proposed by @Cory Walker with the extensions from @Rafael and the one form @Tex witch was a bit complicated for me and came up with a solution that is hopefully

    error-proof with javascript and CSS disabled.

    It manipulates with the background-color of the form field to show/hide the label.

    
    
    
    
    
    
    
    
    
    

    View the script in action: http://mattr.co.uk/work/form_label.html

提交回复
热议问题