검색된 요소를 완전 제거 하는 예제입니다.
07.Remove.htm |
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<title>검색된 요소를 완전 제거</title>
<style type="text/css">
div { background-color:Yellow;
}
</style>
<script src="../jQuery/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에 추가 가능 }); //[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> |
결과화면 |
[그림43-1] |
'jQuery | javascript | CSS' 카테고리의 다른 글
44.jQuery - Width와 Height값 크기 구하기 ( 06.CSS ) (0) | 2009.11.11 |
---|---|
-- 현재 까지의 jQuery 소스5 -- (0) | 2009.11.11 |
42.jQuery - ReplaceWith ( 05.Maripulation - 06.ReplaceWith ) (0) | 2009.11.11 |
41.jQuery - Clone ( 05.Maripulation - 05.Clone ) (0) | 2009.11.11 |
40.jQuery - Wrap ( 05.Maripulation - 04.Wrap ) (0) | 2009.11.11 |
Comments