Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta http-equiv="X-UA-Compatible" content="ie=edge" />
- <title>Document</title>
- </head>
- <body>
- <div>
- <form class="form1" action="submit">
- <input type="radio" name="radio1" class="radio" value="a" />a
- <input type="radio" name="radio1" class="radio" value="b" />b
- <input type="radio" name="radio1" class="radio" value="c" />c
- </form>
- </div>
- </body>
- </html>
- <script>
- var radio = document.querySelectorAll(".radio")
- for (var i = 0; i < radio.length; i++) {
- radio[i].onclick = function() {
- switch(this.value) {
- case "a":
- console.log("here is for a");
- break;
- case "b":
- console.log("b block");
- break;
- case "c":
- console.log("c block!");
- break;
- default:
- console.log("if error?")
- }
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement