我有一个文本框,显示一些默认文本.在鼠标悬停时,文本将消失,用户可以定期输入:
但是,我想将一些CSS样式应用于默认文本,使其看起来像教学文本而不是其他内容.你对如何做到这一点有什么想法吗?
默认文本为灰色
Onmouseover文本将消失,当用户开始输入时,它将只是常规的黑色.
这是当前的代码:
<textarea
class="textarea"
onblur="if(this.value=='') this.value='Question or topic you need help with (in one sentence)...';"
onfocus="if(this.value=='Question or topic you need help with (in one sentence)...') this.value='';"
id="question"
name="question"
>
Question or topic you need help with (in one sentence)...
</textarea>
Run Code Online (Sandbox Code Playgroud)
谢谢!
Jas*_*aro 10
您应该考虑使用HTML5 placeholder属性.
http://diveintohtml5.ep.io/forms.html#placeholder
这会将文本颜色设置为浅灰色,并在焦点上删除.
| 归档时间: |
|
| 查看次数: |
4569 次 |
| 最近记录: |