教程集 www.jiaochengji.com
教程集 >  jQuery  >  jquery 教程  >  正文 jQuery实现textarea文本框半透明文本提示效果

jQuery实现textarea文本框半透明文本提示效果

发布时间:2015-12-30   编辑:jiaochengji.com
本文介绍了jquery实现textarea文本框中半透明文本提示效果的方法,一例jquery半透明效果的实例代码,感兴趣的朋友参考下。

jquery实现textarea文本框带有半透明文本提示效果:
textarea文本框一般用于编辑大段的文本,比如编辑器或者简单的留言回复之类的功能,有的在textarea文本框的有默认的提示语言。

完整代码:
 

复制代码 代码示例:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.jbxue.com/" />
<title>脚 本 学 堂</title>
<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:green;
z-index:10;
padding:10px;
}
#txtNote{
width:300px;
height:100px;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<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>
留言板:<textarea id="txtNote"></textarea>
<div id="divTips">脚本 学堂 欢迎您</div>
</body>
</html>

您可能感兴趣的文章:
jQuery实现textarea文本框半透明文本提示效果
jquery半透明设置实现代码
半透明效果 blur.js
jquery 半透明遮罩效果示例
css 实现div半透明度实现代码
photoshop设计半透明的塑胶玻璃字效果制作教程
HTML5 Canvas渐进填充与透明实现图像的Mask效果
js实现可拖动的对话框的几个例子
CSS透明实现方法
网页特效之让css使网页图片半透明

关键词: jquery半透明效果  textarea  文本框   
[关闭]
~ ~