일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 워드프레스홈페이지제작
- 카페24
- 네이버웹마스터도구
- Wordpress
- 반응형웹
- 반응형홈페이지
- MySQL
- 워드프레스
- 워드프레스소개
- jQuery
- 영카트
- 자바스크립트
- 댕댕이
- 기업홈페이지제작
- css3
- 플러그인설치방법
- 무료호스팅서버
- 제이쿼리
- 워드프레스란?
- 웹호스팅
- 그누보드
- html5
- 무료호스팅
- 반려견
- JavaScript
- php
- 워드프레스플러그인
- 닷홈
- 병원홈페이지제작
- Linux
- Today
- Total
pm1122dev의 비밀노트
[Jquery] append, appendTo 차이점 본문
api.jquery.com/append/#append-content-content
.append() | jQuery API Documentation
Description: Insert content, specified by the parameter, to the end of each element in the set of matched elements. The .append() method inserts the specified content as the last child of each element in the jQuery collection (To insert it as the first chi
api.jquery.com
api.jquery.com/appendTo/#appendTo-target
.appendTo() | jQuery API Documentation
Description: Insert every element in the set of matched elements to the end of the target. The .append() and .appendTo() methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target. With .ap
api.jquery.com
append와 appendTo의 결과는 같습니다. 다만 차이점이라 한다면 주체가 누가 되느냐가 다릅니다.
예시를 보겠습니다.
html
<div class="box">
<p class="tag">바나나</p>
</div>
jquery
$(function(){
$(".tag").append("<p>딸기</p>");
$("<p>수박</p>").appendTo(".tag");
})
결과
<div class="box">
<p class="tag">바나나</p>
<p>딸기</p>
<p>수박</p>
</div>
'javascript&jquery' 카테고리의 다른 글
[Jquery] 자식요소 찾기 children() (0) | 2021.04.26 |
---|---|
[Jquery] element 내용 비우기 empty() (0) | 2021.04.26 |
slick.js 에러 $(...).slick is not a function 해결방법 (0) | 2021.04.09 |
[jquery] 부모창 제어 opener, parent (0) | 2021.02.04 |
[jquery] element가 동적으로 추가됐을 경우 이벤트 주기 (1) | 2021.02.01 |