반응형
<!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
블로그 이미지

꽃꽂이하는개발자

,