如何在< input>内创建标签元件? [英] How to create a label inside an <input> element?
本文介绍了如何在< input>内创建标签元件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这是一个非常常见的技巧,但我会不知道该怎么做。
什么是最简单/更好的解决方案?
解决方案
< input name =searchboxonfocus =if(this.value =='search')this.value =''type =text值= 搜索 >
更好的例子是SO搜索按钮!这就是我从中获得这些代码的地方。查看页面源代码是一个有价值的工具。
I would like to insert a descriptive text inside an input element that disappers when the user click on it.
I know it is a very common trick, but I do not know how to do that..
What is the simplest/better solution?
解决方案
<input name="searchbox" onfocus="if (this.value=='search') this.value = ''" type="text" value="search">
A better example would be the SO search button! That's where I got this code from. Viewing page source is a valuable tool.
这篇关于如何在< input>内创建标签元件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文