Skip to content

Instantly share code, notes, and snippets.

@matherton
Created August 30, 2018 11:31
Show Gist options
  • Save matherton/c7079f29a55e8ea59da5db7746f7ba27 to your computer and use it in GitHub Desktop.
Save matherton/c7079f29a55e8ea59da5db7746f7ba27 to your computer and use it in GitHub Desktop.
ES6 function for un-selectable radio buttons
radioChecked = () => {
var allRadios = document.querySelectorAll('input[type="radio"]');
allRadios.forEach(r => {
r.addEventListener('mouseup', function(e) {
if (r.checked) {
setTimeout(() => {
r.checked = false;
}, 0);
}
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment