Advertisement
Coldsewoo

Untitled

Jun 2nd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.98 KB | None | 0 0
  1. <html lang="en">
  2.   <head>
  3.     <meta charset="UTF-8" />
  4.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  5.     <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  6.     <title>Document</title>
  7.   </head>
  8.   <body>
  9.     <div>
  10.       <form class="form1" action="submit">
  11.         <input type="radio" name="radio1" class="radio" value="a" />a
  12.         <input type="radio" name="radio1" class="radio" value="b" />b
  13.         <input type="radio" name="radio1" class="radio" value="c" />c
  14.       </form>
  15.     </div>
  16.   </body>
  17. </html>
  18.  
  19. <script>
  20. var radio = document.querySelectorAll(".radio")
  21. for (var i = 0; i < radio.length; i++) {
  22.  radio[i].onclick = function() {
  23.    switch(this.value) {
  24.      case "a":
  25.        console.log("here is for a");
  26.        break;
  27.      case "b":
  28.        console.log("b block");
  29.        break;
  30.      case "c":
  31.        console.log("c block!");
  32.        break;
  33.      default:
  34.        console.log("if error?")
  35.    }
  36.  }
  37. }
  38.  
  39. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement