doesn't show/hide just modifiy the fields type attribute to from 'text' to 'password', and vise versa?
<!DOCTYPE html>
<html>
<head>
<title>Toggle Input Type</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<form>
<input type="text" id="myInput" />
<br />
<button id="toggleBtn">Toggle</button>
</form>
<script>
$(document).ready(function() {
$("#toggleBtn").click(function(e) {
e.preventDefault();
var inputType = $("#myInput").attr("type");
if (inputType === "text") {
$("#myInput").attr("type", "password");
} else if (inputType === "password") {
$("#myInput").attr("type", "text");
}
});
});
</script>
</body>
</html>
