单击时删除输入文本的默认值 [英] Delete default value of an input text on click
问题描述
我有一个输入文本:
I have an input text :
<input name="Email" type="text" id="Email" value="email@abc.com" />
我想要设置一个默认值,例如你的编程问题是什么?在StackOverFlow中,当用户点击它时,默认值为disapear。
I want to put a default value like "What's your programming question ? be specific." in StackOverFlow, and when the user click on it the default value disapear.
推荐答案
<input name="Email" type="text" id="Email" value="email@abc.com" placeholder="What's your programming question ? be specific." />
如果您有HTML5文档类型和符合HTML5的浏览器,则可以使用。但是,目前许多浏览器都不支持,因此至少Internet Explorer用户将无法看到您的占位符。不过,请参阅 http://www.kamikazemusic.com/quick-tips / jquery-html5-placeholder-fix / ( archive.org版本)解决方案。使用它,你将会非常现代且符合标准,同时也为大多数用户提供了功能。
If you have a HTML5 doctype and a HTML5-compliant browser, this will work. However, many browsers do not currently support this, so at least Internet Explorer users will not be able to see your placeholder. However, see http://www.kamikazemusic.com/quick-tips/jquery-html5-placeholder-fix/ (archive.org version) for a solution. Using that, you'll be very modern and standards-compliant, while also providing the functionality to most users.
另外,提供的链接是经过良好测试的, - 开发出来的解决方案,应该可以开箱即用。
Also, the provided link is a well-tested and well-developed solution, which should work out of the box.
这篇关于单击时删除输入文本的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!