JQuery 배열관리

2020/JQuery 2020. 3. 1. 22:18
반응형
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script>
      $(document).ready(function() {
        $("h1").each(function(index) {
          $(this).addClass("high_light_" + index);
          console.log(index);
        });
      });
    </script>
    <style>
      .high_light_0 {
        background-color: yellow;
      }

      .high_light_1 {
        background-color: orange;
      }
      .high_light_2 {
        background-color: blue;
      }
      .high_light_3 {
        background-color: green;
      }

      .high_light_4 {
        background-color: red;
      }
    </style>
    <title>Document</title>
  </head>
  <body>
    <h1>item - 0</h1>
    <h1>item - 1</h1>
    <h1>item - 2</h1>
    <h1>item - 3</h1>
    <h1>item - 4</h1>
  </body>
</html>
반응형

'2020 > JQuery' 카테고리의 다른 글

JQuery 문서 객체 탐색 종료  (0) 2020.03.02
JQuery eq, last, first()  (0) 2020.03.02
JQuery animate()  (0) 2020.03.01
JQuery FadeIn(), FadeOut()  (0) 2020.03.01
Jquery slideDown(), slideUp()  (0) 2020.03.01
블로그 이미지

꽃꽂이하는개발자

,