¾È±Ô °øºÎ¹æ

Javascript & JQuery & CSS > append(), appendTo() - °´Ã¼ Ãß°¡ ¹æ¹ý

µî·ÏÀÏ : 2017-07-13 12:32 Á¶È¸¼ö : 53,336

À¥ÆäÀÌÁö¸¦ °³¹ßÇÏ´Ù º¸¸é µ¿ÀûÀÎ ÆäÀÌÁö¸¦ ¸¸µé¾î¾ß µÉ ¶§°¡ ÀÖ½À´Ï´Ù.

¿©±â¼­ µ¿Àû »ý¼ºÀº Java Script·Î ½ÇÇàÇßÀ» ¶§ ½ºÅ©¸³Æ®°¡ µ¿ÀÛÇϸ鼭 HTMLÄڵ带 ÀÛ¼ºÇØ ÁÖ´Â °ÍÀ» ¸»Çϸç, ÀÌ¿Í ¹Ý´ë·Î Á¤Àû »ý¼ºÀº HTML¹®¼­¸¦ Á÷Á¢ ÀÛ¼ºÇÏ´Â °ÍÀ» ¸»ÇÕ´Ï´Ù.

µ¿ÀûÀÎ ÆäÀÌÁö¸¦ ÀÛ¼ºÇÒ¶§ »ç¿ëÇÏ´Â °ÍÀÌ append() ¸Þ¼­µå³ª appendTo() ¸Þ¼­µå ÀÔ´Ï´Ù.

»ç¿ë¹æ¹ýÀº

$("Ŭ·¡½º¸í").append("Ãß°¡ÇÒ³»¿ë");
-  Ŭ·¡½º¸í µÚ¿¡ Ãß°¡ÇÒ ³»¿ëÀ» »ðÀÔÇÑ´Ù.

$("Ãß°¡ÇÒ³»¿ë").appendTo("Ŭ·¡½º¸í");
- Ãß°¡ÇÒ ³»¿ëÀ» Ŭ·¡½º¸í µÚ¿¡ »ðÀÔÇÑ´Ù.


µÎ ¸Þ¼­µåÀÇ ¿¹Á¦¸¦ º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
 
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<ol>
	<li>List item 1</li>
	<li>List item 2</li>
	<li>List item 3</li>
</ol>

<button id="btn1">Append() text</button>
<button id="btn2">Append() list item</button>
<button id="btn3">appendTo() </button>


<script type="text/javascript">
$(document).ready(function() {
	$("#btn1").click(function(){        
		$("p").append(" <b>Appended text</b>.");
	});

	$("#btn2").click(function() {
		$("ol").append("<li>Appended item</li>");
	});

	$("#btn3").click(function(){
		$("<span>Hello World!</span>").appendTo("p");
	});

});

</script>
¾î·ÆÁö ¾ÊÀº ¿¹Á¦ ÀÔ´Ï´Ù....

°£´ÜÇÑ ¿¹Á¦¸¦ Çϳª´õ º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
 
			<div class="container">
				<div class="hello">Hello</div>
				<div class="goodbye">Goodbye</div>
			</div>
À§¿Í °°Àº HTML űװ¡ Á¸ÀçÇÒ ¶§ ¾Æ·¡ ó·³ appendTo¸¦ »ç¿ëÇÏ°Ô µÇ¸é ¾î¶»°Ô µÉ±î¿ä?
 
$('.hello').appendTo('.goodbye');

DOM ±¸Á¶´Â ¾Æ·¡Ã³·³ ¹Ù²î°Ô µË´Ï´Ù.
 
			<div class="container">
			  <div class="goodbye">
				Goodbye
				<div class="hello">Hello</div>
			  </div>
			</div>
 .append() ÇÔ¼ö´Â ¿øº»¿¡¼­ »õ·Î¿î À§Ä¡·Î À̵¿ÀÌ µË´Ï´Ù.



 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.