Created
October 12, 2020 22:47
-
-
Save eheiser/356e25741ee146a1b968e7aeb364293c to your computer and use it in GitHub Desktop.
Vanilla js day 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en" class="no-js"> | |
<head> | |
<meta charset="utf-8"> | |
<title>HTML template</title> | |
</head> | |
<body> | |
<form class="form p-4"> | |
<div class="form-group"> | |
<label for="username">Username</label> | |
<input type="text" name="username" id="username"> | |
</div> | |
<div class="form-group"> | |
<label for="password">Password</label> | |
<input type="password" name="password" id="password"> | |
</div> | |
<div class="form-group"> | |
<label for="show-password"> | |
<input type="checkbox" name="show-passwords" id="show-password"> | |
Show password | |
</label> | |
</div> | |
<p> | |
<button type="submit" class="btn btn-primary">Log In</button> | |
</p> | |
</form> <!-- #container --> | |
<script> | |
var check = document.querySelector('#show-password'); | |
var password = document.querySelector('#password'); | |
check.addEventListener('click', function (event) { | |
if (check.checked === true) { | |
password.type = 'text'; | |
} | |
else { | |
password.type = 'password'; | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment