jQuery w3schools 한글판 강좌53 -Add Several New Elements With after() and before()
jQuery w3schools 한글판 강좌53 -after(), before()를 이용한 각각의 새 요소 삽입하기
after()와 before() 메소드 역시 무한히 많은 새요소들을 매개변수로 취할수 있습니다.
새요소들은 text/HTML로 생성될수 있으며(이전의 예에서 보셨듯이), jQuery나 자바스크립트코드 그리고 DOM요소를 이용하여 생성할수도 있습니다.
다음 예에서는 각기 새 요소들을 생성합니다.
요소들은 text/HTML, jQuery, 그리고 JavaScript/DOM을 이용해서 생성됩니다.
그런후에 그 텍스트에 after()메소드를 이용하여 새 요소들을 삽입합니다.
(이 방법은 before()메소드도 같은 방식으로 사용가능합니다):
Example
function afterText() {
var txt1 = "<b>I </b>"; // HTML이용 요소 생성
var txt2 = $("<i></i>").text("love "); // jQuery 이용 생성
var txt3 = document.createElement("b"); // DOM 을 이용 생성
txt3.innerHTML = "jQuery!";
$("img").after(txt1, txt2, txt3); // <img>뒤에 새 요소들 삽입
}
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4556 | jQuery |
프로그래머7
|
8년 전 | 1691 | |
| 4555 | jQuery |
프로그래머7
|
8년 전 | 1610 | |
| 4554 | jQuery |
프로그래머7
|
8년 전 | 1665 | |
| 4553 | jQuery |
프로그래머7
|
8년 전 | 2041 | |
| 4552 | PHP | 8년 전 | 1880 | ||
| 4551 | PHP | 8년 전 | 1468 | ||
| 4550 | PHP | 8년 전 | 1708 | ||
| 4549 | jQuery |
프로그래머7
|
8년 전 | 2745 | |
| 4548 | jQuery |
프로그래머7
|
8년 전 | 1443 | |
| 4547 | jQuery |
프로그래머7
|
8년 전 | 1368 | |
| 4546 | jQuery |
프로그래머7
|
8년 전 | 1684 | |
| 4545 | jQuery |
프로그래머7
|
8년 전 | 1712 | |
| 4544 | jQuery |
프로그래머7
|
8년 전 | 1866 | |
| 4543 | jQuery |
프로그래머7
|
8년 전 | 1653 | |
| 4542 | jQuery |
프로그래머7
|
8년 전 | 1585 | |
| 4541 | jQuery |
프로그래머7
|
8년 전 | 1634 | |
| 4540 | jQuery |
프로그래머7
|
8년 전 | 1667 | |
| 4539 | jQuery |
프로그래머7
|
8년 전 | 1864 | |
| 4538 | jQuery |
프로그래머7
|
8년 전 | 1536 | |
| 4537 | jQuery |
프로그래머7
|
8년 전 | 1698 | |
| 4536 | jQuery |
프로그래머7
|
8년 전 | 1936 | |
| 4535 | jQuery |
프로그래머7
|
8년 전 | 1521 | |
| 4534 | jQuery |
프로그래머7
|
8년 전 | 1856 | |
| 4533 | jQuery |
프로그래머7
|
8년 전 | 2346 | |
| 4532 | jQuery |
프로그래머7
|
8년 전 | 1918 | |
| 4531 | PHP |
|
8년 전 | 3714 | |
| 4530 | jQuery |
프로그래머7
|
8년 전 | 1801 | |
| 4529 | jQuery |
프로그래머7
|
8년 전 | 1903 | |
| 4528 | jQuery |
프로그래머7
|
8년 전 | 1701 | |
| 4527 | jQuery |
|
8년 전 | 2700 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기