jQuery 수업

jQuery-2(더블클릭)

줄라이퍼스트 2020. 2. 19. 10:38

 

※ doubleclick() 사용

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            // p tag를 double click하면, p tag가 화면에서
            // 사라지게 하게 할려면?
            $("p").dblclick(function(){
                 $(this).hide();
            });
        });
    </script>
</head>
<body>

    <p>If you double-click on me, I will disappear.</p>
    <p>Click me away!</p>
    <p>Click me too!</p>
    <h3>this is h3</h3>
    <h4>this is h4</h4>
    
</body>
</html>

 

※ 실행화면