I'm trying to default set a radio button with HTML. In the browser I have:
<label><input type="radio" checked="checked" name="optradio" i="1">Nein</label>
But the radio button is not selected.
What do I do wrong?
I'm trying to default set a radio button with HTML. In the browser I have:
<label><input type="radio" checked="checked" name="optradio" i="1">Nein</label>
But the radio button is not selected.
What do I do wrong?
My bad. I had another radio button later on the page that was also checked and had the same name="optradio". It would uncheck the first no matter where it is ~~:-|
$(function() {
$("div").html( `
<div class="radio radio1">
<label><input type="radio" checked="checked" name="optradio" i="1">Nein</label>
</div>
<div class="radio radio3">
<label><input type="radio" checked="checked" name="optradio" i="3">2</label>
</div>
` )
;
})
See Codepen: https://codepen.io/lafisrap/pen/yXVyWR?editors=1010
<label><input type="radio" name="optradio" checked>Nein</label>
we can also use single checked rather then using checked="checked".
if u need further clarifications please read and try this. https://www.w3schools.com/tags/att_input_checked.asp