JavaScript adds event listener through addeventlistener

From , 4 Years ago, written in JavaScript, viewed 51 times.
URL https://pastebin.vip/view/70c767c2
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. <!DOCTYPE html>
  24. <html lang="en">
  25. <head>
  26.   <title>This text is the title of the document</title>
  27.   <script>
  28.     function showalert(){
  29.       alert('you clicked me!');
  30.     }
  31.     function clickme(){
  32.       var pelement=document.getElementsByTagName('p')[0];
  33.       pelement.addEventListener('click', showalert, false);
  34.     }
  35.     window.addEventListener('load', clickme, false);
  36.   </script>
  37. </head>
  38. <body>
  39.   <div id="main">
  40.     <p>Click Me</p>
  41.     <p>You Can't Click Me</p>
  42.  </div>
  43. </body>
  44. </html>
  45. //javascript/5025

Reply to "JavaScript adds event listener through addeventlistener"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website