如果用户单击该复选框,我试图在何处显示输入框中的密码作为文本。如果他/她取消选中,它会将属性设置为密码。任何指针?
代码:
<!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>
原文由 BoeNoe 发布,翻译遵循 CC BY-SA 4.0 许可协议
您在选择器中的测试输入之前缺少 # 并且每次单击它时都需要检查复选框的状态