我想让用户点击复选框,它会在输入框中显示密码为文本。如果他/她取消选中,它将该属性设置为密码。任何指针?jQuery显示密码
代码:
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='jquery-3.1.1.min.js'></script>
<script type='text/javascript' src='jquery-ui/jquery-ui.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('#check').click(function(){
if($('test-input').attr('type', 'text'));
});
});
</script>
</head>
<body>
<input type='password' id='test-input' /> Show password <input type='checkbox' id='check' />
</body>
</html>
[与jQuery变化类型输入栏的(可能的重复http://stackoverflow.com/questions/1544317/change-type-of-input-field-with-jquery ) – Alex