How do I auto-hide placeholder text upon focus using css or jquery?

后端 未结 26 1830
长情又很酷
长情又很酷 2020-11-28 00:39

This is done automatically for every browser except Chrome.

I\'m guessing I have to specifically target Chrome.

Any solutio

26条回答
  •  执笔经年
    2020-11-28 01:22

    For a pure CSS based solution:

    input:focus::-webkit-input-placeholder  {color:transparent;}
    input:focus::-moz-placeholder   {color:transparent;}
    input:-moz-placeholder   {color:transparent;}
    

    Note: Not yet supported by all browser vendors.

    Reference: Hide placeholder text on focus with CSS by Ilia Raiskin.

提交回复
热议问题