• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>jQuery Element Remove</title>
7
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
8
    <script>
9
        $(function() {
10
            $("button").on("click", function() {
11
                // class가 "content"인 요소 중에서 class가 각각 "first", "second"인 요소를 모두 삭제함.
12
                $(".content").remove(".first, .second");
13
            });
14
        });
15
    </script>
16
</head>
17
​
18
<body>
19
​
20
    <h1>.remove() 메소드</h1>
21
    <div>
22
        <div class="content first">첫 번째 컨텐츠에요!</div>
23
        <div class="content second">두 번째 컨텐츠에요!</div>
24
        <div class="content third">세 번째 컨텐츠에요!</div>
25
    </div>
26
    <br>
27
    <button>div 요소 삭제</button>
28
    
29
</body>
30
​
31
</html>