Javascript ITL 23092026

This commit is contained in:
2026-09-23 11:16:37 +02:00
parent 3b7d2349da
commit 72a94ecde8
4 changed files with 133 additions and 1 deletions
+50
View File
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Second Javascript</title>
<link rel="stylesheet" href="assets/css/02.css">
</head>
<body>
<div class="container">
<h2>Login</h2>
<label for="username">Benutzername</label>
<input type="text" name="userName" id="username" placeholder="Jonny">
<br><br>
<label for="password">Passwort</label>
<input type="password" id="togglePasswordBtn" name="passWord" placeholder="Password"><br><br>
<button id="togglePasswordBtn" onclick="togglePassword()">Passwort anzeigen/ausblenden</button><br>
<button id="togglePasswordBtn2">Passwort anzeigen/ausblenden</button>
</div>
<script>
function togglePassword(){
var passwordField = document.getElementById("togglePasswordBtn");
if(passwordField.type === 'password'){
passwordField.type = 'text';
}
else if(passwordField.type === 'text'){
passwordField.type = 'password';
}
}
document.getElementById('togglePasswordBtn2').addEventListener('click', function() {
var passwordField2 = document.getElementById("togglePasswordBtn");
if(passwordField2.type === 'password'){
passwordField2.type = 'text';
}
else if(passwordField2.type === 'text'){
passwordField2.type = 'password';
}
});
</script>
</body>
</html>