Blog Content

    티스토리 뷰

    47.jQuery - unbind 메서드로 이벤트 바인딩 해제 ( 07.Events )

    반응형
    02.Unbind.htm

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

        <title>이벤트 처리기 해제</title>

        <script src="../jQuery/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

        <script type="text/javascript">

            $(document).ready(function() {

                //[!] 버튼 클릭시 메시지 출력

                $('#btn').click(function() { alert('클릭됨'); });

                //[1] unbind() 메서드로 지정된 이벤트 해제

                $('#btnUnbind').one("click", function() {

                    $('#btn').unbind("click"); //바인딩 해제

                });

            });

        </script>

       

    </head>

    <body>

        <div id="my">

            <input type="button" id="btn" value="버튼" class="hover" />

            <input type="button" id="btnUnbind" value="이벤트 해제" class="hover" />

        </div>

    </body>

    </html>



    결과화면

    [그림47-1]


        버튼을 클릭하면 메세지 박스가 출력
       이벤트 해제 버튼을 클릭 후 버튼 클릭시 아무런 반응이 없음


    반응형

    Comments