Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of resetting an HTML radio button to unchecked using JavaScript.
<style type="text/css">
label { display: block; }
<label><input type="radio" name="q" id="radio-a" value="A"> A</label>
<label><input type="radio" name="q" id="radio-b" value="B"> B</label>
<label><input type="radio" name="q" id="radio-c" value="C"> C</label>
<a href="#" id="clear-button">Clear</a>
<script type="text/javascript">
document.getElementById('clear-button').addEventListener('click', function () {
["radio-a", "radio-b", "radio-c"].forEach(function(id) {
document.getElementById(id).checked = false;
return false;

This comment has been minimized.

Copy link

@Inforcekid Inforcekid commented Mar 5, 2019

The part Clear should be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment