Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
  8. <link rel="stylesheet" href="style.css">
  9. <title>Jquery</title>
  10.  
  11. <style>
  12. #box{
  13. width: 200px;
  14. height: 200px;
  15. background-color: red;
  16. position: relative;
  17. }
  18.  
  19. #cookie{
  20. background-color: grey;
  21. color: white;
  22. width: 100%;
  23. padding: 20px;
  24. position: fixed;
  25. top: 0;
  26. left: 0;
  27. display: none;
  28. }
  29.  
  30. #cookie a{
  31. color: orange;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36.  
  37. <h2 id="hello">Hello</h2>
  38.  
  39. <div id="box">
  40.  
  41. Hello
  42. <p>Dette er en box</p>
  43. </div>
  44. <button id="klik">Klik her</button>
  45.  
  46.  
  47. <input type="text" name="name" placeholder="Name">
  48. <span id="name-error"></span>
  49.  
  50. <input type="text" name="phone" placeholder="Phone">
  51. <span id="phone-error"></span>
  52.  
  53. <button id="submit">Send</button>
  54.  
  55.  
  56. <div id="cookie">
  57. <p>We use cookies on this site</p> <a href="#">learn more</a>
  58. <button id="accept">Accept</button>
  59. </div>
  60.  
  61. <script
  62. src="https://code.jquery.com/jquery-3.4.1.min.js"
  63. integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  64. crossorigin="anonymous"></script>
  65. <script>
  66. $(function(){
  67. $("#hello").click(function(){
  68. $("#hello").css("color", "red");
  69. $("#hello").text("Hej");
  70. });
  71.  
  72.  
  73. /*$("#klik").click(function(){
  74. $("#box").css("background-color", "yellow").text("Hej igen").fadeOut(2000);
  75. //$("#box p, #hello").text("Du klikkede pƄ knappen");
  76. //$("#box").slideToggle(2000);
  77. //$("#box:contains('pƄ')").css("color", "blue");
  78. });*/
  79.  
  80.  
  81. $("input").blur(function(){
  82. if($(this).val() == ""){
  83. $("#" + this.name + "-error").text("Please fill out the " + this.name + " field.").css("color", "red");
  84. }else{
  85. $("#" + this.name + "-error").text("");
  86. }
  87. });
  88.  
  89. $("input").keyup(function(){
  90. if($(this).val() == ""){
  91. $("#" + this.name + "-error").text("Please fill out the " + this.name + " field.").css("color", "red");
  92. }else{
  93. $("#" + this.name + "-error").text("");
  94. }
  95. });
  96.  
  97.  
  98. if(sessionStorage.getItem("cookie") != "shown"){
  99. $("#cookie").delay(2000).fadeIn(1000);
  100.  
  101. $("#accept").click(function(){
  102. $("#cookie").fadeOut();
  103. sessionStorage.setItem("cookie", "shown");
  104. });
  105. };
  106.  
  107. $("#klik").click(function(){
  108. $('#box').animate({
  109. left: "+=140px"
  110. });
  111. })
  112.  
  113.  
  114. });
  115. </script>
  116. </body>
  117. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement