jQuery | javascript | CSS

43.jQuery - Remove ( 05.Maripulation - 07.Remove )

Godffs 2009. 11. 11. 13:21
반응형
remove : DOM에서 요소를 제거
    검색된 요소를 완전 제거 하는 예제입니다.

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]



반응형