input提示文字颜色(input标签placeholder属性)

周未休息,感觉没啥可写的,就水一篇文章吧,说一说前端 html 页面中 input 元素中在没有值的情况下,添加提示的文字,当要输入文字的时候,提示的文字消失。

关于 html input 输入框的提示文字,有两种方法可以实现,一种为 input 元素的 placeholder 属性,一种为 js 方法。

input 元素的 placeholder 属性

placeholder:属性提供可描述输入字段预期值的提示信息

语法:

<input placeholder="提示的文字">

例:input 添加提示的文字

代码:

<input type="text" placeholder="这里是提示的文字">

运行结果:

当input输入框,输出文字时,提示的文字信息会消失

input提示文字颜色(input标签placeholder属性)

注:

1、js 方法添加的提示文字不同于 使用 placeholder 属性添加的效果

2、placeholder 属性添加的提示文字,只有输入内容时文字才会消失

3、js 方式添加的提示文字,当光标定位到 input 输入框中时,提示文字就会消失

(0)
小多多的头像小多多创始人

相关推荐

发表回复

登录后才能评论