jquery 处理密码输入框(input type="password" ) 模仿placeholder
2015-10-22 11:34
696 查看
html
jquery
<form method="post" action=""> <ul> <li> <span>邮箱</span> <input type="text" name="email" value="请输入邮箱" onfocus="if(value == '请输入邮箱'){value =''}" onblur="if(value == ''){value ='请输入邮箱'}" > </li> <li> <span>密码</span> <input name="" type="text" value="密码" id="text" > <input name="" type="password" style="display:none;" id="password"> </li> <li> <span>验证码</span> <input type="text" name="code" class="code"> <img src=""> </li> <li> <span></span> <label><input type="checkbox" checked="checked" name="check" class="checked"><i>记住密码</i></label> <a href="" class="forget">忘记密码</a> </li> <li> <span></span> <a href="" class="login-btn">登录</a> </li> </ul> </form>
jquery
<script type="text/javascript"> function _password(hid,pid){ var _hid = $("#"+hid); var _pid = $("#"+pid); _hid.focus(function(){ var _hval = $.trim($(this).val()); if(_hval != "密码") return; $(this).css("display","none"); _pid.css("display","block").val("").focus(); }); _pid.blur(function(){ var _hval = $.trim($(this).val()); if(_hval != "") return; $(this).css("display","none"); _hid.css("display","block").val("密码"); }) } _password('text','password') </script>
相关文章推荐
- Asp.net +Jquery-uploadify多文件上传
- JQuery中$.ajax()方法参数详解
- 利用jQuery和CSS实现环形进度条
- jQuery学习笔记之三
- jquery 实现tab选项卡功能
- jQuery常用的元素查找方法总结
- jquery的$.extend和$.fn.extend作用及区别
- jquery-jquery替换getElementsByTagName
- zip文件jQuery工作地点选择城市代码
- 后台管理引入jQuery,使用ajax是提示"$.ajax无效..."
- jQuery - 左右拖动分隔条
- DOTA轮播
- jquery实现textarea高度自适应
- jquery操作元素的位置
- jquery input file show image preview 预览图片
- jQuery 用法
- 考试倒计时jquery+cookie(防止刷新)
- jquery通过ajax-json访问java后台传递参数,通过request.getParameter获取不到参数的说明
- PHP+Mysql+jQuery查询和列表框选择操作实例讲解
- jQuery+PHP发布的内容进行无刷新分页(Fckeditor)