Advertisement
here2share

HTML .on click demo

Aug 12th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.58 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="utf-8">
  5.   <title>on demo</title>
  6.   <style>
  7.   p {
  8.     background: yellow;
  9.     font-weight: bold;
  10.     cursor: pointer;
  11.     padding: 5px;
  12.   }
  13.   p.over {
  14.     background: #ccc;
  15.   }
  16.   span {
  17.     color: red;
  18.   }
  19.   </style>
  20.   <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  21. </head>
  22. <body>
  23.  
  24. <p>Click me!</p>
  25. <span></span>
  26.  
  27. <script>
  28. var count = 0;
  29. $( "body" ).on( "click", "p", function() {
  30.   $( this ).after( "<p>Another paragraph! " + (++count) + "</p>" );
  31. });
  32. </script>
  33.  
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement