HTML5 “placeholder” support

前端 未结 5 1871
傲寒
傲寒 2020-12-18 21:44

How can I find out if the browser supports the HTML5 placeholder tag, so I can decide whether to hook my jQuery placeholder plugin or not.

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 22:07

    To get a broad idea go to:

    http://caniuse.com/#search=placeholder

    And to test in the browser you can do:

    function supportsPlaceholder() {
      var i = document.createElement('input');
      return 'placeholder' in i;
    }
    

提交回复
热议问题