输入框灰色文字

Input box grey text

我怎样才能使输入框具有淡​​淡的灰色文本,当您在框中输入内容时该文本就会消失。

例如。当您以“是否有用于在向量中查找索引元素的 R 函数”的形式提问时,存在于“标题”输入框中。

您要找的是 placeholder。这是一个例子:

<input type="text" placeholder="Type something here">

这是 textarea 的另一个例子:

<textarea rows="4" cols="50" placeholder="Describe yourself here..."></textarea>

那个模糊的文本叫做占位符。

您可以使用 'placeholder' 属性将其放在自己的文本字段中。

<input type="text" placeholder="This is first name" />