Advertisement
GameNCode

Javascript Exercises

Mar 27th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <!-- Roy The Fuckin King Weisfeld-->
  6.  
  7. <img id="myImage" onclick="changeImage()" src="pic_bulboff.gif" width="100" height="180">
  8.  
  9. <p>Click the light bulb to turn on/off the light.</p>
  10.  
  11. <p>Write something in the text field to trigger a function.</p>
  12.  
  13. <input type="text" id="myInput" oninput="myFunction()">
  14.  
  15. <p id="demo2"></p>
  16.  
  17. <script>
  18. function myFunction() {
  19. var x = document.getElementById("myInput").value;
  20. document.getElementById("demo2").innerHTML = "You fucking wrote: " + x;
  21. }
  22. function changeImage() {
  23. var image = document.getElementById('myImage');
  24. if (image.src.match("bulbon")) {
  25. image.src = "images/bulboff.gif";
  26. } else {
  27. image.src = "images/bulbon.gif";
  28. }
  29. }
  30. </script>
  31. <p id="demo">JavaScript can change HTML content.</p>
  32.  
  33. <button type="button" onclick='document.getElementById("demo").innerHTML = "I Double Dare You MotherFucker!"'>Click Me! I Dare You</button>
  34.  
  35. <p id="demo3">JavaScript can change the style of an HTML element.</p>
  36.  
  37. <button type="button" onclick="document.getElementById('demo3').style.fontSize='35px'">Click Me!</button>
  38.  
  39. <!-- Roy The Fuckin King Weisfeld-->
  40.  
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement