1 Example(s) of JQuery Multiple events


Description :

You can use n numbers of events in one method. Here we are using two events in the given example.


JQuery Multiple events Example - 1
<!DOCTYPE html>
<html>

<head>
    <title>Welcome to LearnKode - A code learning platform</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
    <script>
        $(document).ready(function() {
            $(".sample").on({
                click: function() {
                    $("p").text("Text changed on single click");
                },
                dblclick: function() {
                    $("p").text("Text changed on double click");
                }
            })
        });
    </script>
</head>

<body>
    <button class="sample">Click on Appwrk</button>
    <p>sample Text</p>
</body>

</html>

<!-- In this example we are going to change the content of p tag using multiple event handlers with the help of on() function. -->

Output