1.IE中密码输入无法替换type的解决方法
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function onfocuspwd(obj, otherObj) {
obj.hide();
otherObj.show();
otherObj.focus();
}
function onblurpwd(otherObj, obj) {
if (otherObj.val().length == 0) {
otherObj.hide();
obj.show();
}
}
</script>
</head>
<body>
<input id="txtPassword" type="text" value="输入密码" onfocus="onfocuspwd($(this),$('#txtPwd'));" />
<input id="txtPwd" type="password" style="display: none" onblur="onblurpwd($(this),$('#txtPassword'))" />
</body>
</html>
<head>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function onfocuspwd(obj, otherObj) {
obj.hide();
otherObj.show();
otherObj.focus();
}
function onblurpwd(otherObj, obj) {
if (otherObj.val().length == 0) {
otherObj.hide();
obj.show();
}
}
</script>
</head>
<body>
<input id="txtPassword" type="text" value="输入密码" onfocus="onfocuspwd($(this),$('#txtPwd'));" />
<input id="txtPwd" type="password" style="display: none" onblur="onblurpwd($(this),$('#txtPassword'))" />
</body>
</html>
2.不需要获取焦点的替换方式
var obj = document.getElementById("radio");
obj.outerHTML = obj.outerHTML.replace(/type=(?:"[^"]+"|'[^']+'|[^"' >]+)/i, "type='checkbox'");