动态改变input type属性的变通方法
2008-10-26 23:31
531 查看
<SCRIPT type=text/javascript><!--
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
//-->
</SCRIPT>
<SCRIPT src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript>
</SCRIPT>
<SCRIPT> window.google_render_ad(); </SCRIPT>
<IFRAME name=google_ads_frame marginWidth=0 marginHeight=0 src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&dt=1225035063187&lmt=1219829505&prev_slotnames=1891601125&output=html&slotname=3685991503&correlator=1225035063140&url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1413.html&eid=30143001&ea=0&ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__72.html&frm=0&ga_vid=829866576.1224664711&ga_sid=1225034957&ga_hid=1315437805&ga_fc=true&flash=9.0.124.0&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameBorder=0 width=300 scrolling=no height=250 allowTransparency></IFRAME>一个密码框,在密码框里提示输入密码,也就是"请输入您的密码"当然把这里由text设置成password,那这里value的内容都会显示*****了,我要显示明文,但是点击后,"请输入您的密码"消失,再输入的是******
type为只读属性不能改变,只能创建一个临时input来显示当光标移到时切换到实际的input中,以下是通过测试的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>zdz</title>
<script type="text/javascript">
function changeType(obj)
{
obj.style.display = "none";
document.getElementById("d2").style.display = "";
document.getElementById("d2").focus();
}
</script>
</head>
<body>
<div id="Edit">
<input type="text" id="d1" value="请输入您的密码" size="14" maxlength="20" onfocus="changeType(this);" style="display:" />
<input type="password" id="d2" value="" size="14" maxlength="20" style="display:none" />
</div>
</body>
</html>
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
//-->
</SCRIPT>
<SCRIPT src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript>
</SCRIPT>
<SCRIPT> window.google_render_ad(); </SCRIPT>
<IFRAME name=google_ads_frame marginWidth=0 marginHeight=0 src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&dt=1225035063187&lmt=1219829505&prev_slotnames=1891601125&output=html&slotname=3685991503&correlator=1225035063140&url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1413.html&eid=30143001&ea=0&ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__72.html&frm=0&ga_vid=829866576.1224664711&ga_sid=1225034957&ga_hid=1315437805&ga_fc=true&flash=9.0.124.0&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameBorder=0 width=300 scrolling=no height=250 allowTransparency></IFRAME>一个密码框,在密码框里提示输入密码,也就是"请输入您的密码"当然把这里由text设置成password,那这里value的内容都会显示*****了,我要显示明文,但是点击后,"请输入您的密码"消失,再输入的是******
type为只读属性不能改变,只能创建一个临时input来显示当光标移到时切换到实际的input中,以下是通过测试的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>zdz</title>
<script type="text/javascript">
function changeType(obj)
{
obj.style.display = "none";
document.getElementById("d2").style.display = "";
document.getElementById("d2").focus();
}
</script>
</head>
<body>
<div id="Edit">
<input type="text" id="d1" value="请输入您的密码" size="14" maxlength="20" onfocus="changeType(this);" style="display:" />
<input type="password" id="d2" value="" size="14" maxlength="20" style="display:none" />
</div>
</body>
</html>
相关文章推荐
- 如何动态改变input type=submit 的type属性为button
- jquery的attr方法不能改变input的type属性
- js动态修改input输入框的type属性(实现方法解析)
- js动态修改input输入框的type属性(实现方法解析)
- JS动态改变form表单里的action值属性的方法
- html input type text标签属性和方法事件
- 【DOM操作】实时监听input[type='text']和HTML标签中属性改变事件
- 修改input的type属性的几种方法
- JS 动态修改 input 的 type 属性 - teresa502的专栏 - 博客频道 - CSDN.NET http://blog.csdn.net/teresa502/article/details/6546361
- JQuery获取input type="text"中的value属性的值的方法
- html input type text标签属性和方法事件
- jquery动态改变onclick属性导致失效的问题解决方法
- [Flex] 总结一下动态改变属性的方法
- 用JS动态改变表单form里的action值属性的两种方法
- JS 动态修改 input 的 type 属性
- JavaScript动态改变div属性的实现方法
- jq改变input的type属性实现密码显示隐藏的切换
- Javascript 动态改变imput type属性
- html input type text标签属性和方法事件 (一)
- Android控件EditText的属性InputType的一些经验及动态设置TYPE_NUMBER_FLAG_DECIMAL无效的原因