如何在html和javascript中的文本框中添加文本值 [英] How to add a text value in text box in html and javascript

查看:91
本文介绍了如何在html和javascript中的文本框中添加文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在html和javascript中的文本框中添加文本值。当你加载网站;文本框必须显示示例值在此输入您的姓名,当用户点击文本框时,它会自动清除在此输入您的姓名值。我正在使用HTML和Javascript开发我的网站。请帮忙吗?

提前谢谢。

解决方案

您可以将输入标签的value属性设置为您想要的值。



例如< input value =something/>



参见本页: http://www.w3schools.com/tags/att_input_value.asp [ ^ ]







如果你刚刚开始;访问此处: http://www.w3schools.com/ [ ^ ]


Davids解决方案将帮助您走上正确的道路。

以下是使用jQuery完成此操作的示例以及解释代码的文章。

http://www.davidjrush.com/blog/2011/10/jquery-creating-a-textbox-text-watermark/ [ ^ ]

How to add a text value in text box in html and javascript. when you load the website; the textbox has to show the sample value "Enter Your Name Here", when the user hit the textbox, it has clear the "Enter Your Name Here" value automatically. i am developing my website using HTML and Javascript. can any one help out please?
Thanks in advance.

解决方案

You set the value attribute of the input tag to the value you want.

e.g. <input value="something" />

See this page: http://www.w3schools.com/tags/att_input_value.asp[^]



If you are just starting out; visit here: http://www.w3schools.com/[^]


Davids solution is going to get you on the right path.
Here is an example of using jQuery to accomplish this along with an article that explains the code.
http://www.davidjrush.com/blog/2011/10/jquery-creating-a-textbox-text-watermark/[^]


这篇关于如何在html和javascript中的文本框中添加文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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