diff --git a/src/dom/dom.js b/src/dom/dom.js index a845db2203..9bd87a1b97 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -952,9 +952,17 @@ p5.prototype.createRadio = function() { } } } else { + // forEach loop to uncheck all radio buttons before + // setting any one as checked. + self._getOptionsArray().forEach(option => { + option.checked = false; + option.removeAttribute('checked'); + }); + for (const option of self._getOptionsArray()) { if (option.value === value) { option.setAttribute('checked', true); + option.checked = true; result = option; } }