Manipulation - Clone() 메서드 (검색된 요소를 복사하기)
.NET프로그래밍/jQuery 1.3.2 2009. 11. 11. 10:50 |
[Clone.htm]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>검색된 요소를 복사하기</title>
<style type="text/css">
#menu { background-color:Blue; color:White; }
#submenu { background-color:Silver; }
#content { height:100px; }
</style>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
//[!] 상단 메뉴를 복사(Clone)해서 하단 메뉴에 추가(Append)
$('#menu').clone().insertBefore('#submenu');
$('#menu').clone().prependTo('#submenu');
// 원래 하단 메뉴가 있는 위치
$('#menu').clone().appendTo('#submenu');
$('#menu').clone().insertAfter('#submenu');
});
</script>
</head>
<body>
<div id="menu">
HOME About
</div>
<div id="content">
상단 메뉴를 아래 하단메뉴에 복사
</div>
<div id="submenu">
여기는 하단메뉴 들어오는 곳
</div>
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
Manipulation - Remove() 메서드 (검색된 요소를 완전 제거) (0) | 2009.11.11 |
---|---|
Manipulation - ReplaceWith() 메서드 (검색된 요소를 변경하기) (0) | 2009.11.11 |
Manipulation - Wrap()메서드 (검색된 요소를 특정 태그로 감싸기) (0) | 2009.11.11 |
Manipulation - 특정 용어에 대해서 번호 붙이기 (0) | 2009.11.11 |
Manipulation - DOM 요소의 앞/뒤에 요소 추가 (0) | 2009.11.11 |