在运行时单击文本框后,默认文本应消失 [英] default text should disappear after click on textbox at run time

查看:105
本文介绍了在运行时单击文本框后,默认文本应消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
如何做到这一点,以便用户单击搜索文本字段时,
默认条目(在这种情况下为搜索")会自动删除-它们
然后面对一个空白的搜索框,可以立即键入
在此先感谢

Hi All
How do I make it so that when a user clicks in a search text field, the
default entry (in this case "Search") is removed automatically - they
are then faced with a blank search box and can type straight away
Thanks in advance

推荐答案

您正在谈论的文本框水印.就像我们在CP for Search中在右上角广告下方的顶部绿色栏中所显示的那样.

这是通过使用Javascript完成的.您有几种选择:
1.根据需要即时编写类似行为的Javasscript-您需要在文本框的onfocus/onclick/onkeydown(任何此类事件)上引发一个事件并清除其值.
2.制作具有此行为的自定义控件并使用它.
3.使用现有的第三方控件.例如: AJAX工具包TextBoxWatermark演示 [
You are talking of Textbox Watermarks. Like the one we have here in CP for Search in the Top Green bar just below the Ad at top-right corner.

It is done via using Javascript. You have few options:
1. Write your own Javasscript for the similar behavior on the fly as and when required - You would need to raise an event onfocus/onclick/onkeydown (any such event) of the textbox and clear it''s value.
2. Make a custom control that has this behaviour and use it.
3. Use existing thrid party controls. For example: AJAX toolkit TextBoxWatermark Demonstration[^]

I would prefer 2 or 3.


尝试此链接

点击 [
Try this Link

Click[^]


这篇关于在运行时单击文本框后,默认文本应消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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