ref.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.success {
background-color: green;
}
.failure {
background-color: brown;
}
input {
background-color: lightpink;
}
</style>
</head>
<body>
<input type="password" id="password">
<button onclick="validate()">클릭</button>
<script>
function validate() {
let input = document.querySelector('input');
input.className = "";
if (input.value === '0000') {
input.classList.add('success');
} else {
input.classList.add('failure');
}
}
</script>
</body>
</html>
'React' 카테고리의 다른 글
[React] CHELSEA Football Club 사이트 (0) | 2023.03.09 |
---|---|
[React] 포트폴리오 (0) | 2023.03.09 |