mardi 2 avril 2019

Find Checkbox in HTML Table Using JQuery Find Method

I have a HTML table which has the following structure:

<table id="myTable">
  <tr>
     <td><input type="text" name="FullName" value="Tom" /></td>
     <td><input type="checkbox" name="isActive" /></td>
     <td><a href="javascript:void(0);" class="edit">Edit</a>
  </tr>
</table>

When the user clicks the 'edit' link, a Javascript function is called (see below). In this function I need to get the data from the table, i.e., FullName and whether or not isActive has been checked.

 $("#namedTutors").on('click', '.editTutor', function () {
    var tr = $(this).closest("tr");
    var fullName = tr.find("input[name=FullName]").val();
});

I can get the FullName easy enough, but I'm having difficulties retrieving the data to see if isActive has been checked/ticked or not.

Could someone please help.

Thanks.




Aucun commentaire:

Enregistrer un commentaire