当用户输入用户名时,清除默认文本

Wiping out default text when user will enter a username

本文关键字:用户 清除 默认 文本 输入      更新时间:2023-09-26

我想使用JavaScript清除默认文本,并允许用户输入自己选择的单词。我如何将这个东西与我的HTML代码集成。我需要它来测试。下面是我的HTML代码。

<html>
<body bgcolor="black"><form method="get" action ="http://localhost:2013">
<center>
<font color="white" size=65>Enter Word: 
<input type="text" name="word"></font></center>
</br><center>
<font color="Green" size=65>
<input type="submit" value="SUBMIT"></font></center><
form>
</body>
</html>

有什么建议吗?

<!DOCTYPE html>
<body bgcolor="black"><form method="get" action ="http://localhost:2013">
<center>
<font color="white" size=65>Enter Word: 
<input type="text" name="word" placeholder='Default Text'></font></center>
</br><center>
<font color="Green" size=65>
<input type="submit" value="SUBMIT"></font></center><
form>
</body>
</html>

只需在输入元素中添加placeholder='Default Text'即可。

不需要太多物品,这将帮助您。。。

<form action="demo_form">
  <input type="text" name="fname" placeholder="Your default text"><br>
  <input type="text" name="lname" placeholder="Your default text"><br>
</form>