我有一個默認值爲「password」的文本輸入。使用jQuery將HTML文本輸入更改爲密碼輸入
當用戶點擊這一領域,即當焦點設置爲文本框此,我想改變輸入類型密碼..
我已經使用jQuery試過,但沒有喜悅:
$("#passwordtxt").click(function(e){
e.stopPropagation();
if($("#passwordtxt").val() == "Password"){
$("#passwordtxt").val("");
}
$("#passwordtxt").attr('type','password');
});
這裏是它適用於HTML:
<form name = "loginform" action = "get_login.php" method = "post">
<input id = "emailtxt" name = "username" type="text" size="25" value = "E-mail"/>
<input id = "passwordtxt" name = "password" type="text" size="25" value = "Password"/>
</form>
結果:它沒有類型更改密碼,它只是停留文本...
什麼不起作用? – arnaud576875