包含默认文本的文本框

Text box with default text

本文关键字:文本 包含 默认      更新时间:2023-09-26

我有一个带有默认文本的文本框。当用户点击它时,我正在使用javascript来消除它,但我想让它在没有javascript的情况下工作。有没有办法在html或php中做到这一点?谢谢!

它可以

在平面HTML5中使用<input>标签的placeholder属性来完成

<input type="text" placeholder="Default Text" />

在HTML5中,引入了名为placeholder

你可以这样使用它

<input type="text" placeholder="text to show and hide" />
很简单,

你也可以使用html5控件。喜欢。

<input  type="text" name="txtFirstName" id="txtFirstName"
placeholder="enter first name" />