I would like to make a structure with the condition (if-else) RadioButton
I want that when the Radiobutton RB1 is selected, this function is ac
Check if they're checked with the el.checked attribute.
Docs or this Question
let radio1 = document.querySelector('.radio1');
let radio2 = document.querySelector('.radio2');
let output = document.querySelector('.output');
function update() {
if (radio1.checked) {
output.innerHTML = "radio1";
}
else {
output.innerHTML = "radio2";
}
}
update();