Getting value of radio button by id using jquery

I kinda new to jQuery so I get a little trouble. How do I code to get the value of a radio button by its id? The solution propose from any other similar questions kinda confuses me. Below are the codes:

$(document).on("click", "#Update", function() {
  let id = $(this).data('id');
  let tank_name = $(this).data('tank_name');
  let title = $(this).data('title');
  let tank_maintain = $(this).data('tank_maintain');
  let work_status = $(this).data('work_status');

  $("#t_maintenanceID").val(id);
  $("#tank_name").val(tank_name);
  $("#title_maintenance").val(title);
  $("#tank_maintain").val(tank_maintain);
  $("work_status:checked").val(work_status);

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<fieldset class="form-group">
  <div class="row">
    <label class="col-form-label col-sm-2 pt-0">Priority:</label>
    <div class="col-sm-10">
      <div class="form-check">
        <input class="form-check-input" type="radio" name="work_status" id="work_status" value="High">
        <label class="form-check-label" for="work_status">
                  High
                </label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="radio" name="work_status" id="work_status" value="Medium">
        <label class="form-check-label" for="work_status">
                  Medium
                </label>
      </div>
      <div class="form-check">
        <input class="form-check-input" type="radio" name="work_status" id="work_status" value="Low">
        <label class="form-check-label" for="work_status">
                  Low
                </label>
      </div>
    </div>
  </div>
</fieldset>

107 thoughts on “Getting value of radio button by id using jquery”

Leave a Comment