jquery 02 다중 이벤트 처리하기

프론트엔드/Jquery|2021. 3. 17. 19:34
Document

문서 준비 이벤트에는 여러 다중 이벤트를 정의할 수 있습니다.

버튼을 클릭하면 이벤트 처리를 합니다.

 

<!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>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script>
    $(document).ready(function() {
      $("button.hide").click(function(){
        $("p").hide();
      });
      $("button.show").click(function(){
        $("p").show();
      });
      
    });
  </script>
</head>
<body>
  <p>문서 준비 이벤트에는 여러 다중 이벤트를 정의할 수 있습니다.</p>
  <p>버튼을 클릭하면 이벤트 처리를 합니다.</p>
  <button class="hide">메시지 삭제</button>
  <button class="show">메시지 보기</button>

</body>
</html>

댓글()
구독