[One.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

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

<head>

    <title>one()메서드로 한번만 실행</title>

    <style type="text/css">   

    </style>

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

    <script type="text/javascript">

        $(document).ready(function () {

            //[!] bind(), click() 메서드와 달리 one() 메서드는 딱 한번만 실행되고, 이벤트가 해제됨.

            $("#my .hover").one("click", function () { alert('한번만 클릭'); });

        });

    </script>

</head>

<body>

 

<div id="my">

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

</div>

 

</body>

</html>

 




-------------------------------------------------------------------------------------




[실행결과]

--> 아래그림에서 '버튼'을  처음에 한번 클릭하면 아래그림과 같이 '메시지박스'가 출력되지만, 메시지박스의 '확인'버튼을 눌러서 메시지박스를 닫은 후 다시 '버튼'을 클릭해보면...





--> 더 이상 메시지박스가 출력되지 않는다.



Posted by holland14
: