JQuery 하나의 폼에 버튼 여러 개 처리

1 개요[ | ]

jQuery 하나의 폼에 버튼 여러 개 처리
<form id="form1">
  <input type="email" name="email" placeholder="이메일" />
  <button type="submit">보내기</button>
  <button type="button" id="btn-save">임시저장</button>
  <button type="button" id="btn-help">도움말</button>
</form>

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
  $("#form1").submit(function(e) {
    if ($(this).children("[name=email]").val().length < 1) {
      alert("이메일을 입력해주세요.");
      e.preventDefault();
      return;
    }
    alert("메일을 보냅니다.");
  });
  $("#btn-save").click(function() {
    alert("임시로 저장합니다.");
  });
  $("#btn-help").click(function() {
    alert("도움말을 보여줍니다.");
  });

</script>

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}