queryslectorAll
by Raidek
HTML
<div class="form-check form-check-inline">
<input
class="form-check-input radio"
type="radio"
name="inlineRadioOptions5"
id="Yes"
value="1"
/>
<label class="form-check-label" for="Yes">SĂ</label>
</div>
<div class="form-check form-check-inline">
<input
class="form-check-input radio"
type="radio"
name="inlineRadioOptions5"
id="No"
value="0"
/>
<label class="form-check-label" for="No">No</label>
</div>
JavaScript
document.addEventListener("DOMContentLoaded", function() {
var el = document.querySelectorAll(".radio");
var t0 = performance.now();
el.forEach(item => {
item.addEventListener("change", function(e) {
console.log(e.target.id);
});
});
document.getElementById("Yes").checked = true;
document.getElementById("No").checked = true;
var t1 = performance.now();
//console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
});