Advertisement
Felanpro

Function in Javascript (Example)

Dec 4th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.  
  6. <style>
  7. #button1 {
  8. height: 50px;
  9. width: 76px;
  10. background-color: blue;
  11. color: yellow;
  12. border: 3px solid green;
  13. }
  14. </style>
  15.  
  16. </head>
  17.  
  18. <body>
  19.  
  20. <h1 id="demo">This Text Is Going To Change After Someone Click The Lonely Button!</h1>
  21.  
  22. <button type ="button" id="button1" onclick="randomFunction()">Click me!</button>
  23.  
  24. <script>
  25.  
  26. function randomFunction()
  27. {
  28.    document.getElementById("demo").innerHTML = "THANK YOU, YOU CHANGED ME!";
  29. }
  30.  
  31. </script>
  32.  
  33.  
  34.  
  35.  
  36. </body>
  37.  
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement