Skip to content

Instantly share code, notes, and snippets.

@vijjusri14
Created March 11, 2019 06:07
Show Gist options
  • Select an option

  • Save vijjusri14/280171cc0c58a785cf9791e2385ad6ed to your computer and use it in GitHub Desktop.

Select an option

Save vijjusri14/280171cc0c58a785cf9791e2385ad6ed to your computer and use it in GitHub Desktop.
Set input field type as password on focus out using Jquery
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<h2>Jquery Text2Pass</h2>
<input type="text" id="text2Pass" />
<script>
$(document).ready(function() {
$('#text2Pass')
.on('blur', function() {
this.type = 'password';
})
.on('focus', function() {
this.type = 'text';
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment