- <input name="password" type="text" id="showPwd" tabindex="2" class="input" value="密码" />
<input name="password" type="text" id="showPwd" tabindex="2" class="input" value="密码" />
- $("#showPwd").focus(function(){
- $(this).attr('type','password');
- });
$("#showPwd").focus(function(){ $(this).attr('type','password'); });
- // We can't allow the type property to be changed (since it causes problems in IE)
- if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
- jQuery.error( "type property can't be changed" );
- }
// We can't allow the type property to be changed (since it causes problems in IE) if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { jQuery.error( "type property can't be changed" ); }
- $("#pwd").focus(function(){
- $("#pwd")[0].type = 'password';
- $("#pwd").val("");
- });
$("#pwd").focus(function(){ $("#pwd")[0].type = 'password'; $("#pwd").val(""); });
- $("#showPwd").focus(function(){
- alert($("#showPwd")[0].type);
- $("#showPwd")[0].type = 'password';
- $("#showPwd").val("");
- });
$("#showPwd").focus(function(){ alert($("#showPwd")[0].type); $("#showPwd")[0].type = 'password'; $("#showPwd").val(""); });
- <input name="password" type="password" id="password" class="input" style="display: none;" />
<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();
- }
- });
$("#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(); } });
最终效果: 当输入框获得焦点的时,输入的内容显示为“****”;当失去焦点的时,内容为空时显示“密码”。
实例代码:
<script type="text/javascript">
function test(){
$("#showPwd").focus(function() {
var text_value = $(this).val();
var defv = this.defaultValue;
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();
}
});
}
function checkValue(obj){
if(obj.value==''){
obj.style.display='none';
document.getElementById('repassword_f').style.display='';
}
}
</script>
密码3:<input name="password" type="text" id="showPwd" tabindex="2" class="input" value="请输入密码" />
<input name="password" type="password" id="password" class="input" style="display: none;" />
<br/><br/>
密码5:<input type="text" id="repassword_f" value="请输入密码" onclick="this.style.display='none';document.getElementById('repassword').style.display='';document.getElementById('repassword').focus();"/>
<input name="repassword" type="password" id="repassword" onblur="checkValue(this);" style="display:none"/>
相关推荐
js实现input输入框输入信息后出现下拉选择框,下拉框的数据源可以使根据输入的值从数据库中动态获取
本文是对js动态修改input输入框的type属性的实现方法。进行了详细的介绍,需要的朋友可以过来参考下,希望对大家有所帮助
主要介绍了jQuery实现动态添加、删除按钮及input输入框的方法,涉及jQuery事件响应及页面元素动态操作相关实现技巧,需要的朋友可以参考下
js修改input的type属性有些限制。当input元素还未插入文档流之前,是可以修改它的值的,在ie和ff下都没问题。但如果input已经存在于页面,其type属性在ie下就成了只读属性了,不可以修改。在ff下仍是可读写属性。 ...
分享一个用纯 CSS3 实现的,漂亮的 input 输入框动画样式库-Text input love。 点击每个输入框都用不同的动画效果,始终显示标签label,并显示 placeholder(占位符)文本。 演示地址:...
代码主要实现点击添加多个input输入框,并对每个输入框里的数据进行判断
input输入框获取js点击文字内容是一款js输入框特效,无jquery,只需点击div,input输入框会自动获取输入的内容。
js-input输入框提示语
在本篇文章里小编给大家整理的是一篇关于jQuery/JS监听input输入框值变化实例内容,需要的朋友们学习下。
input输入框蓝光特效
JSP中使用JavaScript动态插入删除输入框实现代码.docx
js控制input输入城市名称特效代码,模仿携程网地区搜索样式 当input输入框获取焦点后,自动下拉显示按照字母字段排序的筛选框 城市名称的排序、内容均在js中可以任意修改 使用方法: 1、在网页head...
为减少页面空间占用,将图片按钮放置在input输入框中,兼容火狐、谷歌和IE,图片自行替换
点击input输入框弹出选择层(基于jquery) 网页特效,网页模板,导航菜单,焦点幻灯片,JS代码
今天小编就为大家分享一篇VUE.js实现动态设置输入框disabled属性,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
JS 仿支付宝input文本输入框放大组件,基于Jquery动态显示
——学习参考资料:仅用于个人学习使用! javascript代码-使用js验证input输入框(字母,数字,符号,中文)的源代码
这是一款基于vue2.0的input输入框文字特效。该input输入框特效在输入框聚焦时,为输入框添加多种动画效果,极大提高交互效果。
但是,element并不支持autofocus属性,那就只能通过原生的js效果获取聚焦效果了 document.getElementById("input").focus(); 或者利用vue的ref属性也可以实现聚焦效果: 原理其实很简单,Element 已经提供了 ...