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

后端 未结 26 1838
长情又很酷
长情又很酷 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:14

    $("input[placeholder]").each(function () {
        $(this).attr("data-placeholder", this.placeholder);
    
        $(this).bind("focus", function () {
            this.placeholder = '';
        });
        $(this).bind("blur", function () {
            this.placeholder = $(this).attr("data-placeholder");
        });
    });
    

提交回复
热议问题