반응형
<!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>
      //removeAttr
      // 선택된 엘리먼트(요소)에서 하나 이상의 속성을 제거
      // $(selector).removeAttr(attribute)
      // $('p').removeAttr('style');
      $(document).ready(function() {
        $("button").click(function() {
          $("p").removeAttr("style");
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <p style="font-size:120%; color:red">This is a paragraph.</p>
    <p style="font-weight:bold; color:blue">This is another paragraph.</p>

    <button>Remove the style attribute from all p elements</button>
  </body>
</html>
반응형

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

JQuery odd, even 위치 필터선택자  (0) 2020.03.03
JQuery clone(), 문서 객체 복제  (0) 2020.03.03
JQuery 특정 태그 선택 find()  (0) 2020.03.03
JQuery is()  (0) 2020.03.02
jquery 문서 객체 추가 선택(add)  (0) 2020.03.02
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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>
      //find : $(selector).find(filter)
      // 일반 선택자로 선택 및 XML 문서에서 데이터 추출 시 사용
      var xml = "";
      xml += "<phones>";
      xml += "<phone>";
      xml += "<name>갤럭시노트10</name>";
      xml += "<manufacturer>SAMSUNG</manufacturer>";
      xml += "</phone>";
      xml += "<phone>";
      xml += "<name>G6</name>";
      xml += "<manufacturer>LG</manufacturer>";
      xml += "</phone>";
      xml += "<phone>";
      xml += "<name>아이폰 10</name>";
      xml += "<manufacturer>APPLE</manufacturer>";
      xml += "</phone>";
      xml += "</phones>";

      $(document).ready(function() {
        xmlDOC = $.parseXML(xml);

        console.log(xmlDOC);
        $(xmlDOC)
          .find("phone")
          .each(function(index) {
            var output = "";

            output += "<div>";
            output +=
              "<h1>" +
              $(this)
                .find("name")
                .text() +
              "</h1>";
            output +=
              "<p>" +
              $(this)
                .find("manufacturer")
                .text() +
              "</p>";
            output += "</div>";

            document.body.innerHTML += output;
          });
      });
    </script>
    <title>Document</title>
  </head>
  <body></body>
</html>
반응형

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

JQuery clone(), 문서 객체 복제  (0) 2020.03.03
JQuery removeAttr() , 문서객체 속성 제거  (0) 2020.03.03
JQuery is()  (0) 2020.03.02
jquery 문서 객체 추가 선택(add)  (0) 2020.03.02
JQuery 문서 객체 탐색 종료  (0) 2020.03.02
블로그 이미지

꽃꽂이하는개발자

,

JQuery is()

2020/JQuery 2020. 3. 2. 18:32
반응형
<!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>
      // is : 문서 객체의 특징을 판별
      //$(selector).is(selectorElement, function(index, element))
      $(document).ready(function() {
        $("h1").each(function() {
          if ($(this).is(".header")) {
            $(this).css("color", "blue");
          }
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <h1 class="header">너를 향한</h1>
    <h1>나의 마음은</h1>
    <h1 class="header">Blue</h1>
  </body>
</html>
반응형

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

JQuery removeAttr() , 문서객체 속성 제거  (0) 2020.03.03
JQuery 특정 태그 선택 find()  (0) 2020.03.03
jquery 문서 객체 추가 선택(add)  (0) 2020.03.02
JQuery 문서 객체 탐색 종료  (0) 2020.03.02
JQuery eq, last, first()  (0) 2020.03.02
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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>
        // add : 기존 그룹에 엘리멘트 추가
        //$(selector).add(element, context)
        $(document).ready(function(){
            $('h1').css('color', 'red').add('h2').css('float', 'left');
        });
    </script>
    <title>Document</title>
</head>
<body>
    <h1>오늘 하루는</h1>
    <h2>뭘 할까 하다가</h1>
    <h1>jquery를 공부좀 해봤어</h1>
    <h2>이거하고 음..스프링 공부좀할까?</h1>
    <h1>너의 생각은 어떠니?</h1>
</body>
</html>

 

반응형

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

JQuery 특정 태그 선택 find()  (0) 2020.03.03
JQuery is()  (0) 2020.03.02
JQuery 문서 객체 탐색 종료  (0) 2020.03.02
JQuery eq, last, first()  (0) 2020.03.02
JQuery 배열관리  (0) 2020.03.01
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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")
          .css("background-color", "#c9c9c9")
          .filter(":even")
          .css("color", "red")
          .end()
          .filter(":odd")
          .css("color", "blue");
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <h1>안녕</h1>
    <h1>오늘 하루 너는 어땟니?</h1>
    <h1>너무 힘들면 하루 쉬어가</h1>
    <h1>제일 소중한건 너니까</h1>
    <h1>하루 이틀 쉰다고 인생이 변하지는 않아.</h1>
    <h1>너무 쉬면 변한다...</h1>
  </body>
</html>
반응형

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

JQuery is()  (0) 2020.03.02
jquery 문서 객체 추가 선택(add)  (0) 2020.03.02
JQuery eq, last, first()  (0) 2020.03.02
JQuery 배열관리  (0) 2020.03.01
JQuery animate()  (0) 2020.03.01
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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>
      // eq : $(selector).eq(index)
      // first : $(selector).first()
      // last : $(selector).last()
      $(document).ready(function() {
        $("p")
          .eq(2)
          .css("background-color", "red");
        $("p")
          .first()
          .css("background-color", "blue");
        $("p")
          .last()
          .css("background-color", "gray");
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <h1>안녕..개발자는 참 힘든거 같아..</h1>
    <p>할게 너무 많거든..</p>
    <p>그런데 재미는 있다</p>
    <p>하지만 재미로만 살 수 없거든..가족도 있구..</p>
    <p>도전하고자 하는 사람 도전해!</p>
  </body>
</html>
반응형

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

jquery 문서 객체 추가 선택(add)  (0) 2020.03.02
JQuery 문서 객체 탐색 종료  (0) 2020.03.02
JQuery 배열관리  (0) 2020.03.01
JQuery animate()  (0) 2020.03.01
JQuery FadeIn(), FadeOut()  (0) 2020.03.01
블로그 이미지

꽃꽂이하는개발자

,

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
블로그 이미지

꽃꽂이하는개발자

,

JQuery animate()

2020/JQuery 2020. 3. 1. 22:09
반응형
<!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>
      //(selector).animate({styles}, speed,  easing, callback)
      $(document).ready(function() {
        $("#btn1").click(function() {
          $("#box").animate({ height: "300px" });
        });
        $("#btn2").click(function() {
          $("#box").animate({ height: "100px" }, 3000);
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <button id="btn1">Animate height</button>
    <button id="btn2">Reset height</button>

    <div
      id="box"
      style="background:#98bf21;height:100px;width:100px;margin:15px;"
    ></div>
  </body>
</html>
반응형

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

JQuery eq, last, first()  (0) 2020.03.02
JQuery 배열관리  (0) 2020.03.01
JQuery FadeIn(), FadeOut()  (0) 2020.03.01
Jquery slideDown(), slideUp()  (0) 2020.03.01
JQuery on, off(이벤트 연결 및 제거)  (0) 2020.02.29
블로그 이미지

꽃꽂이하는개발자

,