-2

I have parent element like:

<span style="background: yellow; padding: 50px;" onClick="setCheckBox()"><span>
<span> </span> <input type="checkbox" name="f01" value="100"></span></span>

and js function:

function setCheckBox() {
 document.getElementsByTagName('input'[0].checked = 'true';
}

Want to change the checkbox input on parent click (yellow color)

Thanks in advance!

MT0
  • 143,790
  • 11
  • 59
  • 117
Pavlos
  • 13
  • 8

1 Answers1

1

you would use .checked = true; like so

document.getElementsByTagName('input')[0].checked = true;
  <input type="checkbox" name="f01" value="100">
Mordor
  • 84
  • 6