• 코드:
​x
 
1
<!DOCTYPE html>
2
<html lang="ko">
3
​
4
<head>
5
    <meta charset="UTF-8">
6
    <title>jQuery Event</title>
7
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
8
    <script>
9
        $(function() {
10
            $("button").one("click", function() {
11
                // 모든 <button>요소가 처음 클릭됐을 때에만 실행됨.
12
                $("#text").append("첫 번째 클릭이에요!<br>");
13
                // 모든 <button>요소가 두 번째 클릭됐을 때부터는 이 이벤트 핸들러가 실행됨.
14
                $(this).click(function() {
15
                    $("#text").append("이 버튼을 벌써 클릭했네요!<br>");
16
                });
17
            });
18
        });
19
    </script>
20
</head>
21
​
22
<body>
23
​
24
    <h1>.one() 메소드</h1>
25
    <button>마우스를 클릭해 보세요!</button>
26
    <p id="text"></p>
27
    
28
</body>
29
​
30
</html>