Im making a function which one gets input checked on page loads, this have an unique id created by shopify, so i got a code in jquery which works fine, but im trying to get it to plain javascript (Vanilla) is anyone able to guide me :)
JQUERY version
(function() {
$("#variantRadios input:checked").each(function() {
console.log(this.id + " is checked")
});
})();
Here is Vanilla JS code:
(function () {
const checkVariants = document.querySelectorAll("#variantRadios input:checked");
checkVariants.forEach((checkVariant) => {
console.log(this.id + " is checked")
});
})();