Advertisement
Yuvalxp8

JavaScript Examples

Apr 4th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <style>
  5.         body
  6.         {
  7.         background-image: url("https://i.ytimg.com/vi/cNycdfFEgBc/maxresdefault.jpg");
  8.         color: blue;
  9.         }
  10.     </style>
  11.     <script>
  12.         function myFunction() {
  13.             var x = document.getElementById("myInput").value;
  14.             document.getElementById("demo2").innerHTML = "You wrote: " + x;
  15.         }
  16.         function changeImage() {
  17.             var image = document.getElementById('myImage');
  18.             if (image.src.match("On")) {
  19.                 image.src = "Off.gif";
  20.             } else {
  21.                 image.src = "On.gif";
  22.             }
  23.         }
  24.     </script>
  25. </head>
  26. <body>
  27.  
  28. <img id="myImage" onclick="changeImage()" src="Off.gif" width="100" height="180">
  29.  
  30. <p>Click The Picture Above To Turn On / Off </p>
  31.  
  32. <p>Write here and see what happens</p>
  33.  
  34. <input type="text" id="myInput" oninput="myFunction()">
  35.  
  36. <p id="demo2"></p>
  37.  
  38.  
  39. <p id="demo">JS Is Capable of changing HTML Stuff.</p>
  40.  
  41. <button type="button" onclick='document.getElementById("demo").innerHTML = "OMG IT CHANGED !!!"'>Click Here </button>
  42.  
  43. <p id="demo3">JS Can Change css Stuff</p>
  44.  
  45. <button type="button" onclick="document.getElementById('demo3').style.fontSize='35px'">Click Here Also </button>
  46.  
  47.  
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement