当用户输入用户名时清除默认文本 [英] Wiping out default text when user will enter a username

查看:91
本文介绍了当用户输入用户名时清除默认文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用JavaScript来消除默认文本并允许用户输入他的选择词。我如何将这个东西与我的HTML代码整合在一起。我需要它来进行测试。以下是我的HTML代码。

 < html> 
< body bgcolor =black>< form method =getaction =http:// localhost:2013​​>
< center>
< font color =whitesize = 65>输入字词:

< input type =textname =word>< / font><中心],[
< / br>< center>

< font color =Greensize = 65>
< input type =submitvalue =SUBMIT>< / font>< / center><
表格>
< / body>
< / html>

有何建议?

解决方案

 <!DOCTYPE html> 
< body bgcolor =black>< form method =getaction =http:// localhost:2013​​>
< center>
< font color =whitesize = 65>输入单词:

< input type =textname =wordplaceholder ='Default Text'>< /字体>< /中心],[
< / br>< center>

< font color =Greensize = 65>
< input type =submitvalue =SUBMIT>< / font>< / center><
表格>
< / body>
< / html>

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


I want to use JavaScript to wipe out default text and allow user to enter a his choice word. How do I integrate this thing with my HTML code. I need it for testing purpose. Below is my HTML code.

<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>

Any suggestions?

解决方案

<!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>

Just add placeholder='Default Text' to your input element.

这篇关于当用户输入用户名时清除默认文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆