JQUERY/예제들
로그인화면 숨기기 나타내기
나이많은 초보
2022. 8. 25. 16:07
<!DOCTYPE html>
<html>
<head>
<style>
#myForm{
display: none; //숨길수 있도록자리 잡기
}
form .btn {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
width: 100px;
margin-bottom: 10px;
margin-top: 10px;
}
button.btn:hover {
opacity: 0.8;
color: yellow;
}
.cancel:hover {
opacity: 0.8;
background: red;
}
</style>
</head>
<body>
<h2>로그인을 클릭하면 로그인 폼이 나타납니다.</h2>
<button class="open">로그인</button>
<div class="form-popup" id="myForm">
<form action="result.html" method="post">
<fieldset>
<legend>로그인</legend>
<h1>Login</h1>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<br>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<br>
<button type="submit" class="btn">Login</button>
<button type="button" class="btn cancel">Close</button>
</fieldset>
</form>
</div>
<script>
$('label').css({'display':'inline-block', 'width': '80px'});
$(".open").click(function(){
$("#myForm").css('display', 'block'); //클릭시 디스플레이 나타내기
});
$(".cancel").click(function(){
$("#myForm").css('display', 'none'); //클릭시 디스플레이 숨기기
});
</script>