Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>
- How to attach a click and double-click
- event to an element in jQuery?
- </title>
- <script src=
- "https://code.jquery.com/jquery-3.6.0.min.js">
- </script>
- <script>
- $(document).ready(function () {
- $(".clickable_ele").bind("click", function () {
- $("<h4>Single click Event called</h4>")
- .appendTo(".res");
- });
- $(".clickable_ele").bind("dblclick", function () {
- $("<h4>Double click Event called</h4>")
- .appendTo(".res");
- });
- });
- </script>
- <style>
- body {
- text-align: center;
- }
- .clickable_ele {
- font-size: 20px;
- font-weight: bold;
- }
- </style>
- </head>
- <body>
- <div class="clickable_ele">
- Click here
- </div>
- <div class="res"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement