HTML5 和placeholder:如何逐步进行?

发布于 2024-12-12 07:54:19 字数 117 浏览 3 评论 0原文

我正在考虑使用 HTML5 的 placeholder 属性。如果浏览器不支持 HTML5,我可以使用 jQuery 作为后备。但是,如果JS关闭了怎么办?我如何使用渐进增强理念来处理这个问题?

I'm thinking about using HTML5's placeholder attribute. If the browser doesn't support HTML5, I can use jQuery as a fallback. However, what if JS is turned off? How do I handle this using the progressive enhancement philosophy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别再吹冷风 2024-12-19 07:54:19

为什么不显示实际的 元素并用 js 隐藏它?

// js file
$('label').hide();

这样,没有 js,他们就会看到常规标签;使用 js,标签将被删除,您将获得 jquery 占位符或 html5 占位符。

Why don't you show an actual <label> element and hide it with js?

// js file
$('label').hide();

That way, without js, they'll see a regular label; with js, the label will be removed and you'll get either your jquery placeholder, or your html5 placeholder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文