사용자 도구

사이트 도구


wiki:javascript:jquery:jquery_note

문서의 이전 판입니다!


jQuery Tutorial

jQuery Effects

jQuery HTML

jQuery Traversing

jQuery AJAX

jQuery Misc

jQuery References

jQuery UI

before, after, prepend, append

after()

The after() method inserts specified content after the selected elements.

after() 메소드는 선택된 요소의 뒤에 특정 내용을 삽입한다.


<div class="container">
  <h2>Greetings</h2>
  <div class="inner">Hello</div>
  <div class="inner">Goodbye</div>
</div>


$( ".inner" ).after( "<p>Test</p>" );

결과

<div class="container">
  <h2>Greetings</h2>
  <div class="inner">Hello</div>
  <p>Test</p>
  <div class="inner">Goodbye</div>
  <p>Test</p>
</div>

before()

The before() method inserts specified content in front of (before) the selected elements.

before() 메소드는 선택된 요소의 앞에 특정 내용을 삽입한다.


append()

The append() method inserts specified content at the end of the selected elements

append() 메소드는 선택된 요소의 끝(자식 요소)에 특정 내용을 삽입한다.


<h2>Greetings>/h2>
<div class="container">
    <div class="inner">Hello</div>
    <div class="inner">Goodbye</div>
</div>


$('.inner').append('<p>Test</p>');

결과

<h2>Greetings>/h2>
<div class="container">
    <div class="inner">
        Hello
        <p>Test</p>    
    </div>
    <div class="inner">
        Goodbye
        <p>Test</p>    
    </div>
</div>    


prepend()

The prepend() method inserts specified content at the beginning of the selected elements.

prepend() 메소드는 선택된 요소의 시작(자식 요소)에 특정 내용을 삽입한다.
/volume1/web/dokuwiki/data/attic/wiki/javascript/jquery/jquery_note.1666079737.txt.gz · 마지막으로 수정됨: 2022/10/18 16:55 저자 emblim98