<form action="success.html">
<div class="my-3">
<input type="text" class="form-control">
</div>
<div class="my-3">
<input type="password" class="form-control">
</div>
<button type="submit" class="btn btn-primary">전송</button>
<button type="button" class="btn btn-danger" id="close">닫기</button>
</form>
전송버튼을 누르면 success.html 로 이동합니다.
에 입력한 값이 아무것도 없으면 전송버튼을 누를 때 알림을 띄우려면,
// 전송버튼을 누르면
// 저기 <input>에 입력된 값이 공백이면 알림을 띄워주세요
초보자일 땐 위와 같이 미리 어떤 코드를 짜야 하는지 적어두는 습관을 갖자.
조건문 if-else
조건부로 코드를 실행하고 싶으면 if 문법을 쓰면 됩니다.
if (조건식) {
// 실행할 코드..
}
조건식이 참일 때 중괄호 안에 있는 코드가 실행이 됩니다.