Manipulation - Remove() 메서드 (검색된 요소를 완전 제거)
.NET프로그래밍/jQuery 1.3.2 2009. 11. 11. 11:35 |
[Remove.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">
div { background-color:Yellow; }
</style>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
//[1] 내용 지우기
$('#btnEmpty').click(function() {
$('div').empty();
$('div').append("<b>hi</b>"); // div에 추가 기능(div 요소가 남아있다.)
});
//[2] 요소 없애기
$('#btnRemove').click(function() {
$('div').remove();
$('div').append("<b>hi</b>"); // div 요소가 없다.
});
});
</script>
</head>
<body>
<div>
<p>jQuery</p>
<p>Ajax</p>
</div>
<input type="button" id="btnEmpty" value="위 영역 삭제" />
<input type="button" id="btnRemove" value="위 영역 삭제" />
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]
--> 첫 화면.
--> 위의 그림에서 왼쪽 버튼을 누른 후의 화면.(Empty() 메서드로 "div영역"을 삭제해도 "div 요소"가 남아있으므로 아래그림과 같이 "div영역"에 '텍스트'가 출력된다.)
--> 오른쪽버튼을 눌렀을 때의 화면.(Remove() 메서드로 "div영역"을 삭제하면 "div요소"도 함께 삭제되어서 아래그림과 같이 "div영역"이 사라진다.)
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
CSS - OuterWidth() / OuterHeight() 메서드 (검색된 요소의 크기 구하기) (0) | 2009.11.11 |
---|---|
CSS - Width() / Height() 메서드 (검색된 요소의 크기 구하기) (0) | 2009.11.11 |
Manipulation - ReplaceWith() 메서드 (검색된 요소를 변경하기) (0) | 2009.11.11 |
Manipulation - Clone() 메서드 (검색된 요소를 복사하기) (0) | 2009.11.11 |
Manipulation - Wrap()메서드 (검색된 요소를 특정 태그로 감싸기) (0) | 2009.11.11 |