您的位置:首页 > Web前端 > HTML

动态改变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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  input html 测试