반응형
<!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() {
        $("#btn1").click(function() {
          $("img").fadeOut(1000);
        });
        $("#btn2").click(function() {
          $("img").fadeIn(1000);
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <img src="/images/1.png" />

    <button id="btn1">FadeOut</button>
    <button id="btn2">FadeIn</button>
  </body>
</html>
반응형

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

JQuery 배열관리  (0) 2020.03.01
JQuery animate()  (0) 2020.03.01
Jquery slideDown(), slideUp()  (0) 2020.03.01
JQuery on, off(이벤트 연결 및 제거)  (0) 2020.02.29
JQuery insertAfter, insertBefore 요소추가  (0) 2020.02.29
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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>
      //slideDown , slideUp
      $(document).ready(function() {
        $("#btn1").click(function() {
          $("img").slideUp();
        });
        $("#btn2").click(function() {
          $("img").slideDown();
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <img src="/images/1.png" />
    <br /><br />
    <button id="btn1">SlideUp</button>
    <button id="btn2">SlideDown</button>
  </body>
</html>
반응형

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

JQuery animate()  (0) 2020.03.01
JQuery FadeIn(), FadeOut()  (0) 2020.03.01
JQuery on, off(이벤트 연결 및 제거)  (0) 2020.02.29
JQuery insertAfter, insertBefore 요소추가  (0) 2020.02.29
JQuery 요소 추가(형제관계)  (0) 2020.02.29
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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>
      //off는 unbind랑 비슷한듯?
      $(document).ready(function() {
        $("p").on("click", function() {
          $(this).css("background-color", "red");
        });
        $("button").click(function() {
          $("p").off("click");
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <p>Click this paragraph to change its background color</p>
    <p>
      Click the button below and then click on this paragraph.(the click event
      is removed)
    </p>
    <br />
    <button>이벤트제거(off)</button>
  </body>
</html>
반응형

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

JQuery FadeIn(), FadeOut()  (0) 2020.03.01
Jquery slideDown(), slideUp()  (0) 2020.03.01
JQuery insertAfter, insertBefore 요소추가  (0) 2020.02.29
JQuery 요소 추가(형제관계)  (0) 2020.02.29
JQuery 요소 감싸기, 요소 태그 넣기  (0) 2020.02.29
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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() {
        $("#insertBefore").click(function() {
          $("<span>Hello Insert Before</span>").insertBefore("p");
        });
        $("#insertAfter").click(function() {
          $("<span>Hello After Before</span>").insertAfter("p");
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <p>This is a paragraph.</p>
    <p>This is another paragraph</p>
    <button id="insertBefore">insertBefore</button>
    <button id="insertAfter">insertAfter</button>
  </body>
</html>
반응형

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

Jquery slideDown(), slideUp()  (0) 2020.03.01
JQuery on, off(이벤트 연결 및 제거)  (0) 2020.02.29
JQuery 요소 추가(형제관계)  (0) 2020.02.29
JQuery 요소 감싸기, 요소 태그 넣기  (0) 2020.02.29
JQuery selectBox 유효성검사  (0) 2020.02.28
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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() {
        $("#after").click(function() {
          $("p").after("<p>Hello world!</p>");
        });
        $("#before").click(function() {
          $("p").before("<p>Hello world!</p>");
        });
      });
    </script>
    <title>After, Before</title>
  </head>
  <body>
    <button id="after">after</button>
    <button id="before">before</button>

    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
  </body>
</html>
반응형
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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() {
        $("#wrap").click(function() {
          $("p").wrap("<div></div>");
        });
        $("#unwrap").click(function() {
          $("p").unwrap("<div></div>");
        });
        $("#wrapAll").click(function() {
          $("p").wrapAll("<div></div>");
        });
        $("#wrapInner").click(function() {
          $("p").wrapInner("<div></div>");
        });
      });
    </script>
    <title>Document</title>
  </head>
  <body>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>

    <button id="wrap">Wrap</button>
    <button id="unwrap">unwrap</button>
    <button id="wrapAll">wrapALL</button>
    <button id="wrapInner">wrapInner</button>
  </body>
</html>
반응형

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

JQuery insertAfter, insertBefore 요소추가  (0) 2020.02.29
JQuery 요소 추가(형제관계)  (0) 2020.02.29
JQuery selectBox 유효성검사  (0) 2020.02.28
JQuery radio button 유효성 검사  (0) 2020.02.28
JQuery checkBox 유효성 검사  (0) 2020.02.28
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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>
      //value값 가져오기
      function fnValuesel() {
        alert($("#PrettyGirls").val());
      }
      //text값 가져오기
      function fnTextValalert() {
        alert($("#PrettyGirls option:selected").text());
      }
      //인덱스값 가져오기
      function idxValueGo() {
        alert(
          $("#PrettyGirls option").index($("#PrettyGirls option:selected"))
        );
      }

      //value값으로 세렉트 시키는 방법 2가지
      function fnSelectedCombo() {
        var slcNumOp = $("#slcNum option:selected").val();
        console.log(slcNumOp);
        // var slcNumOpval = $("#slcNum option:selected").val();
      }

      function fnRemoveCombo() {
        var slcNumOp = $("#slcNum option:checked").val() - 1;
        console.log(slcNumOp);
        $("#slcNum option:eq('" + slcNumOp + "')").remove();
      }

      function fnAppendCombo() {
        var addSlcNum = $("#PrettyGirls option").size() + 1;
        $("#PrettyGirls").append(
          "<option value='" + addSlcNum + "'>연예인</option>"
        );
      }

      function fnReplaceCombo() {
        var slcNumOp = $("#slcNum option:selected").val() - 1;
        $("#PrettyGirls option:eq('" + slcNumOp + "')").replaceWith(
          "<option value='" +
            $("#slcNum option:selected").text() +
            "'>한효주</option>"
        );
      }
    </script>
    <title>selectBox 유효성 검사</title>
  </head>
  <body>
    <select id="PrettyGirls">
      <option value="numOne">신민아</option>
      <option value="numTwo">전지현</option>
      <option value="numThree">원빈</option>
      <option value="numFour">이나영</option>
      <option value="numFive">장동건</option>
      <option value="numSix">고소영</option>
    </select>

    <input type="button" value="value값" onclick="fnValuesel();" />
    <input type="button" value="text값" onclick="fnTextValalert();" />
    <input type="button" value="index값" onclick="idxValueGo();" />

    <select id="slcNum">
      <option value="1">num1</option>
      <option value="2">num2</option>
      <option value="3">num3</option>
      <option value="4">num4</option>
      <option value="5">num5</option>
      <option value="6">num6</option>
      <option value="7">num7</option>
    </select>

    <input type="button" value="선택" onclick="fnSelectedCombo();" />
    <input type="button" value="제거" onclick="fnRemoveCombo();" />
    <input type="button" value="추가" onclick="fnAppendCombo();" />
    <input type="button" value="교체" onclick="fnReplaceCombo();" />
  </body>
</html>
반응형

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

JQuery 요소 추가(형제관계)  (0) 2020.02.29
JQuery 요소 감싸기, 요소 태그 넣기  (0) 2020.02.29
JQuery radio button 유효성 검사  (0) 2020.02.28
JQuery checkBox 유효성 검사  (0) 2020.02.28
JQuery hide, show  (0) 2020.02.28
블로그 이미지

꽃꽂이하는개발자

,
반응형
<!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() {
        $("#regBtn").click(function() {
          invalidItem();
        });
        function invalidItem() {
          if ($("input[name=gender]:radio:checked").length < 1) {
            alert("성별을 선택하세요");
            return false;
          } else {
            alert("회원가입을 축하합니다.");
          }
        }
      });
    </script>
    <title>radio box 유효성 검사</title>
  </head>
  <body>
    <form>
      <input type="radio" name="gender" value="man" />남성
      <input type="radio" name="gender" value="woman" />여성

      <input type="button" id="regBtn" value="회원가입" />
      <input type="reset" value="취소" />
    </form>
  </body>
</html>
반응형

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

JQuery 요소 감싸기, 요소 태그 넣기  (0) 2020.02.29
JQuery selectBox 유효성검사  (0) 2020.02.28
JQuery checkBox 유효성 검사  (0) 2020.02.28
JQuery hide, show  (0) 2020.02.28
JQuery attr 속성변경  (0) 2020.02.28
블로그 이미지

꽃꽂이하는개발자

,