方法一:
<input name="loginPassword" type="text" class="input" id="loginPassword" autocomplete="off" οnfοcus="this.type='password'"/>
但是type方法在IE下不认
方法二:使用jQuery
$("#loginPassword").attr('type','password');
<td><div id="pwdid"><input name="loginPassword" type="text" class="input" id="loginPassword" autocomplete="off" οnfοcus="changeP()"/></div></td>
$('pwdid').replace('<input name="loginPassword" type="password" class="input" id="loginPassword" autocomplete="off"/>');
添加浏览器识别
function changeP(){
var browserName=navigator.appName;
if (browserName=="Netscape"){
document.getElementById('loginPassword').type ="password";
} else if(browserName=="Microsoft Internet Explorer") {
$('pwdid').replace('<input name="loginPassword" type="password" class="input" id="loginPassword" autocomplete="off"/>');
}
}