如何显示/隐藏焦点上的输入值? [英] How to show/hide input value on focus?

查看:71
本文介绍了如何显示/隐藏焦点上的输入值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络上看到了所有这些,但是想知道是否有人拥有用于EASIEST方式的JavaScript代码,以便在模糊时显示输入值,但隐藏在焦点上.

I see this all over the web, but was wondering if anyone has the JavaScript code for the EASIEST way to show input value on blur, but hide in on focus.

推荐答案

由于这仍然出现在Google上,我想指出的是,对于HTML 5,您可以将占位符属性与输入结合使用,以一并实现一段HTML.

Since this still comes up on google, I'd like to point out that with HTML 5 you can use the placeholder attribute with an input to achieve this in one piece of html.

<input type="text" id="myinput" placeholder="search..." />

占位符现在已成为现代浏览器的标准配置,因此这确实是首选方法.

Placeholder is now standard across modern browsers, so this really would be the preferred method.

这篇关于如何显示/隐藏焦点上的输入值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆