- 요소 제거(본인포함인지 아닌지가 다름)
- remove : 요소를 포함하여 자손요소들까지 같이 제거
- empty : 요소를 제외하고 자손 요소들을 제거
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>요소제거예제</title>
<script src="../JS/jquery.min.js"></script>
<script>
$(function(){
$('#btn1').click(function(){
$('.box1').remove();
})
$('#btn2').click(function(){
$('.box2').empty();
});
});
</script>
<style>
.box1, .box2{
height:50px; background: burlywood; margin-top: 20px;
}
.box1{
background: rosybrown;
}
</style>
</head>
<body>
<button id="btn1">remove</button>
<button id="btn2">empty</button>
<div class="box1">
<input type="text">
</div>
<div class="box2">
<input type="text">
</div>
</body>
</html>
'괴발개발 > Javascript+JQuery' 카테고리의 다른 글
JQ_메뉴선택예제 (0) | 2021.06.23 |
---|---|
JQ_클래스 관련 메소드 (0) | 2021.06.23 |
JQ_input창 추가하기(이력서 경력추가기능) (1) | 2021.06.23 |
JQ_checkbox 선택을 나열(표시)하기 (0) | 2021.06.23 |
JQ_radio(성별선택) (0) | 2021.06.23 |