Check "rtypecheckbox" checkbox when "mandatorycheckbox" checkbox is checked is not working

Check "rtypecheckbox" checkbox when "mandatorycheckbox" checkbox is checked is not working

I want that when the input with "mandatorycheckbox" class is checked that the input with "rtypecheckbox" be also always checked. Do you know why that is not working with code below?

Example: https://jsfiddle.net/7Lz1Lthj/6/

Html:

  1. <table class="table table-striped table-responsive-sm">
  2.   <thead>
  3.     <tr>
  4.       <th scope="col">Info</th>
  5.       <th scope="col">Include</th>
  6.       <th scope="col">Mandatory</th>
  7.     </tr>
  8.   </thead>
  9.   <tbody>
  10.     <tr>
  11.       <td>Phone number</td>
  12.       <td>
  13.         <div class="form-check">
  14.           <input autocomplete="off" name="" class="form-check-input rtypecheckbox" type="checkbox" value="" id="">
  15.           <label class="form-check-label" for="exampleRadios1">
  16.             General
  17.           </label>
  18.         </div>
  19.       </td>
  20.       <td>
  21.         <div class="form-check">
  22.           <input autocomplete="off"  name=""
  23.                  class="form-check-input mandatorycheckbox" type="checkbox" value="" id="">
  24.           <label class="form-check-label" for="exampleRadios1">
  25.             for rtype "General"
  26.           </label>
  27.         </div>
  28.       </td>
  29.     </tr>

  30.   </tbody>
  31. </table>

jQuery:

  1. $(document).ready(function () {
  2.   if(document.getElementByClass('.mandatorycheckbox').checked) {
  3.     $('.rtypecheckbox').prop('checked', true);
  4.   }
  5. });