首页 > 其他 > 详细

一段水印文字的练习

时间:2015-02-27 20:05:25      阅读:233      评论:0      收藏:0      [点我收藏+]

做淘宝登陆页面时登陆框的水印文字的需要,做了如下的练习。

<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="..\jquery\jquery-2.1.3.js" type="text/javascript" ></script>
<style type="text/css">
body,input
{
font-size:18px;
}
.graycss
{
color:#CCCCCC;

}
</style>
<script type="text/javascript">
$(function(){
$("#yourtelephone").keypress(function(e){
if ($(this).attr("inputflag")=="0"){
$(this).attr("inputflag","1");
$(this).val("").removeClass("graycss");

}
event.stopPropagation();
}).keydown(function(e){

if ($(this).attr("inputflag")!="0"){
if ($(this).val().length==0){

$(this).attr("inputflag","0");
$(this).val($(this).attr("telephone")).addClass("graycss");
return false;
}
}
else
{
if(e.key=="Backspace" || e.key=="Del"){return false;};
}
});
});

</script>
</head>
<body>
<form>
<h3>水印提示文字练习</h3>
手机号<input type="text" id="yourtelephone" class="graycss" telephone="输入手机号" inputflag="0" value="输入手机号" />
</form>
</body>

</html>

一段水印文字的练习

原文:http://www.cnblogs.com/shijia-dreamhome/p/4304024.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!