Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74765

Ho to check radio button inside label with javascript

$
0
0

I want to check radio buttons contained in a div based on their parent ID, they set a variable that's used in a function but I can't select them.

<label id="radio-step-1" class="btn btn-radio mx-auto" onclick="step=1;">
  <input type="radio" autocomplete="off">one
</label>
<label id="radio-step-2" class="btn btn-radio mx-auto" onclick="step=2;">
  <input type="radio" autocomplete="off">two
</label>

function setStep(){
  document.querySelector("radio-step-" + step "input[type=radio]").checked = true;
}

Viewing all articles
Browse latest Browse all 74765

Latest Images

Trending Articles



Latest Images