jquery 07 addClass()와 removeClass()메소드

프론트엔드/Jquery|2021. 3. 18. 00:10
Document

HTML5

CSS3

자바스크립트

제이쿼리
<!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.addd").click(function() {
        $("h1.a, h2.b, p.c").addClass("blue");
        $("div.d").addClass("important");
      });
      $("button.removee").click(function() {
        $("h1.a,h2.b,p.c").removeClass("blue");
        $("div.d").removeClass("important");
      });
    });
  </script>
  <style>
    .important{
      font-weight : bold;
      font-size: xy-large;
    }
    .blue{
      color: blue;
    }
  </style>
</head>
<body>
  <h1 class="a">HTML5</h1>
  <h2 class="b">CSS3</h2>
  <P class="c">자바스크립트</P>
  <div class="d">제이쿼리</div>
  <button class="addd">CSS 적용</button>
  <button class="removee">CSS 적용 해제</button>
</body>
</html>

댓글()
구독