Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>JavaScript</title>
  5. </head>
  6. <body>
  7.  
  8. <script>
  9.  
  10. function changeTextB() {
  11. var x = document.getElementById("demo");
  12. x.style.color = "blue";
  13. }
  14.  
  15. function changeTextR() {
  16. var x = document.getElementById("demo");
  17. x.style.color = "red";
  18. }
  19.  
  20. function changeTextBL() {
  21. var x = document.getElementById("demo");
  22. x.style.color = "black";
  23. }
  24.  
  25. function numberTest() {
  26. var x, text;
  27.  
  28. x = document.getElementById("numb").value;
  29.  
  30. if (isNaN(x) || x < 1 || x > 10 || x == 5 ) {
  31. text = "Incorrect";
  32. } else {
  33. text = "Correct";
  34. }
  35. document.getElementById("Output").innerHTML = text;
  36. }
  37.  
  38. </script>
  39.  
  40.  
  41.  
  42. <p id="1"> Before The Test. </p>
  43.  
  44. <button type ="Button"
  45. onclick="document.getElementById('1').innerHTML = ' After The Test. ' ">
  46. Click to test! </button>
  47.  
  48. <button type="Button"
  49. onclick="document.getElementById('1').innerHTML = ' Before The Test. ' ">
  50. Reset! </button>
  51.  
  52. </br><br>-----------------------------------------------------</br>
  53.  
  54. <p id="demo"> Colour. </p>
  55.  
  56. <button type ="button" onclick="changeTextB()"> Blue! </button> <button type="button" onclick="changeTextR()"> Red! </button><button type="button" onclick="changeTextBL()"> Black! </button>
  57.  
  58. </br></br>-----------------------------------------------------</br></br>
  59.  
  60. Input a number between 1 and 10, except 5.
  61. </br>
  62. <input id="numb" type="number">
  63. <button type="button" onclick="numberTest()">Submit</button>
  64. </br>
  65. <p id="Output"></p>
  66.  
  67.  
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement