티스토리 뷰

개발/jquery

after()

개발자와코더사이가 PM일까? 2016. 5. 7. 23:00
반응형

jquery after()에 대해서 알아보려고 합니다.

jquery 홈페이지에는 아래와 같이 정의가 되어져 있습니다.

Insert content, specified by the parameter, after each element in the set of matched elements.

각 맞는 요소 뒤에 내용이나 특별한 변수를 넣을때 사용한다고 합니다. 참 영문 번역을 할때 느끼는 점인데 전문도서를 쓰시는 분들은 정말로대단 하신것 같습니다. 아마도 이해를 다하고 번역을 하시는 것 같습니다. ㅜ.ㅜ


기본적으로 아래와 같이 사용하는데요. .after( function-html ) 1.10때에 새롭게 추가 한것이 신기 합니다.

.after( content [, content ] ) version 1.0

.after( function ) version 1.4

.after( function-html ) version 1.10


하나씩 예제를 보면서 확인을 해볼려고 합니다.
.after( content [, content ] )
[예제]
<div id="test"></div>
[스크립트]
$("#test").after("<div>test</div>");
[예상결과]
<div id="test"></div><div>test</div>

.after( function )
[예제]
<div id="test"></div>
[스크립트]
$("#test").after(function() {
  return "<div>" + test + "</div>";
});
[예상결과]
<div id="test"></div><div>test</div>


.after(function-html )

jquery 홈페이지에는 예제는 없는 것 같고 아래와 같이 설명이 되어져 있는데요. 음 예제도 없고 다른 한국어 블로그에도 잘 자료를 못찾아서 @.@ 잘모르겠습니다. 

A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. 

Receives the index position of the element in the set and the old HTML value of the element as arguments. 

Within the function, this refers to the current element in the set.


오늘 하루도 수고 하셨습니다.


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
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
글 보관함