教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 文本框水印提示效果的简单实现代码

文本框水印提示效果的简单实现代码

发布时间:2014-07-08   编辑:jiaochengji.com
本篇文章主要是对文本框水印提示效果的简单实现代码进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助
复制代码 代码如下:

<!doctype html>
<html>
<head>
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <style type="text/css">
        #divTips{
            filter:alpha(opacity=30); /*IE滤镜,透明度50%*/
            -moz-opacity:0.3; /*Firefox私有,透明度50%*/
            opacity:0.3;/*其他,透明度50%*/
            position: absolute;width: 600px; height: 400px;display:none;color:red;z-index:10;padding:10px;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            var $txtNote = $("#txtNote");
            var $divTips = $("#divTips");
            $txtNote.focus(function () {
                //置焦点时隐藏
                $divTips.hide();
            }).blur(function () {
                //离开时, 如果为空则显示,否则隐藏. 然后定位
                $divTips.toggle($txtNote.val() == "")
                    .css({
                        "left": $txtNote.position().left,
                        "top" : $txtNote.position().top
                    });
            });
            $divTips.click(function () {
                $txtNote.focus();
            });
            $txtNote.blur();
        });
    </script>
</head>
<body>
    留言板<br />
    <textarea id="txtNote" style="width: 600px; height: 400px;"></textarea>
    <div id="divTips">
        亲,欢迎访问,有什么说的就写下来吧!!<br />
        (在下面的框框中留下您的name, 方便的话请留下您的联系方式)
    </div><br />
    <input type="text" value="姓名" /> <input type="text" value="手机/QQ/……" />
</body>
</html>

您可能感兴趣的文章:
asp.net文字水印功能简单代码
asp.net在图片上添加水印效果的代码示例
php 文件上传类与图片处理类的实现代码
简单的php图片上传自动给图片加水印
Agile Carousel
超级好用的php文件上传类(上传、缩略图、水印)
文本框水印提示效果的简单实现代码
php 输出文字到图片上(文字水印)的代码
6款经典实用的jQuery小插件及源码(对话框/提示工具等等)
php图片上加水印或文字的代码举例

关键词: 水印效果   
[关闭]
~ ~