为什么 jQuery 不将 #password_input 的 type 属性更改为密码?
<html>
<head>
<title></title>
<style type="text/css">
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#password_input").attr('type','password');
});
</script>
</head>
<body>
<div id="loginBox">
<form>
<input type="text" id="username_input" name="username" /><br />
<input type="text" id="password_input" name="password" />
</form>
</div>
</body>
</html>
最佳答案
是的,可以。
试试这个
<input type="text" class="pwd">
$('.pwd').click(function(){
$(this).get(0).type='password';
});
关于jquery - 将属性 "type"从文本更改为密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5609165/