unobtrusive “default” text in input WITHOUT jQuery

前端 未结 7 1764
攒了一身酷
攒了一身酷 2021-01-16 22:15

i\'m trying to write unobtrusive default/placeholder text in input (actually, relatively placed label over input, which hides on onFocus

7条回答
  •  离开以前
    2021-01-16 22:48

    This is how I would do it, without JQuery. It grays out the control when it shows the default text, and allows entering the default text if need be. The "title" tag will fallback to a tooltip for people who disable JavaScript:

    
    
    
    
    
    
    

    EDIT: Cleared up the comments a bit, fixed some IE bugs and made it so it looks for tags with title's to make it so different pages have less conversion time rather than individually intitializing the input controls ;-)

提交回复
热议问题