Guest User

Untitled

a guest
Feb 16th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function unCheckRadio(input){
  5. input.checked = false;
  6. input.removeAttribute('onclick');
  7. }
  8.  
  9. function moveON(input){
  10. document.getElementsByName(input.name).forEach(radio => radio.removeAttribute('onclick'));
  11. input.setAttribute('onclick', 'unCheckRadio(this)');
  12. }
  13. </script>
  14. </head>
  15. <body>
  16. <div class="radioInputUncheckableGroup">
  17. <input type="radio" id='t' name='t'/>
  18. <input type="radio" id='t' name='t'/>
  19. <input type="radio" id='t' name='t'/>
  20. </div>
  21.  
  22. <script>
  23. document.querySelectorAll('div.radioInputUncheckableGroup').forEach(div => {
  24. div.querySelectorAll('input[type=radio]').forEach(radio => radio.setAttribute('onchange', 'moveON(this)'));
  25. });
  26. </script>
  27. </body>
  28. </html>
Add Comment
Please, Sign In to add comment