.unwrap()
원문 링크
http://api.jquery.com/unwrap/
함수들
개요 : DOM에서 일치하는 요소들의 부모요소를 제거합니다.
- .unwrap( )
.unwrap() 함수는 요소의 부모를 제거합니다. 반대편에 있는 함수는 .wrap() 입니다. 일치하는 요소 (있다면 그들의 형제요소들도)는 DOM 구조에서 부모요소를 대체합니다.
예 제
문단(p)에 div를 Wrap/unwrap 처리합니다.
<!DOCTYPE html>
<html>
<head>
<style>
div { border: 2px solid blue; }
p { background:yellow; margin:4px; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<button>wrap/unwrap</button>
<p>Hello</p>
<p>cruel</p>
<p>World</p>
<script>
$("button").toggle(function(){
$("p").wrap("<div></div>");
}, function(){
$("p").unwrap();
});</script>
</body>
</html>
미리보기
그럼 즐프하세요.
※ 본 예제는 http://www.jquery.com 에 있는 내용임을 밝힙니다.
'프로그래밍 > jQuery' 카테고리의 다른 글
| jQuery API 정복 - 이벤트 연결하기, bind() (6) | 2011.11.23 |
|---|---|
| jQuery API 정복 - 요소 별로 감싸기, wrapAll() (0) | 2011.11.22 |
| jQuery API 정복 - 넓이 구하기, width() (0) | 2011.11.22 |
| jQuery API 정복 - 요소 감싸기, wrap() (0) | 2011.11.22 |
| jQuery API 정복 - class 토글하기, toggleClass() (0) | 2011.11.22 |
| jQuery API 정복 - 텍스트만 알아내기, text() (5) | 2011.11.22 |
| jQuery API 정복 - 수직 스크롤 이동, scrollTop() (2) | 2011.11.22 |
| jQuery API 정복 - 수평 스크롤 이동, scrollLeft() (0) | 2011.11.22 |