想要达到的效果:

失去焦点时:

密码框失去焦点且为空时显示汉字“密码”、获取焦点时输入内容显示为密码“**********”的实现方法

选中输入时时:

密码框失去焦点且为空时显示汉字“密码”、获取焦点时输入内容显示为密码“**********”的实现方法

通过js动态改变input 的type的属性:

网上已经有相关资料了。这里做一下笔记。原文章地址:http://www.jb51.net/article/43140.htm

<input name=”password” type=”password” id=”password” class=”input” style=”display: none;” />

$(“#showPwd”).focus(function() {
var text_value = $(this).val();
if (text_value == this.defaultValue) {
$(“#showPwd”).hide();
$(“#password”).show().focus();
}
});
$(“#password”).blur(function() {
var text_value = $(this).val();
if (text_value == “”) {
$(“#showPwd”).show();
$(“#password”).hide();
}
});

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-01-09
  • 2021-12-04
  • 2022-12-23
猜你喜欢
  • 2021-11-24
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案