HTML5“占位符”支持 [英] HTML5 "placeholder" support
本文介绍了HTML5“占位符”支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何判断浏览器是否支持HTML5占位符标记,以便我可以决定是否挂钩我的jQuery占位符插件。
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.
推荐答案
var placeholderSupported = ( 'placeholder' in document.createElement('input') );
变量 placeholderSupported
将为 true
,如果它原生支持。否则,它将被设置为 false
。
The variable placeholderSupported
will be true
if it is natively supported. Otherwise, it'll be set to false
.
这篇关于HTML5“占位符”支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文