I have several checkbox fields which are nested in table td's like following:
<td>
<div class="am-checkbox ChangeCheckbox"> <input id="check20" type="checkbox" checked="checked"> <label for="check10"> </label> </div>
</td>
Now all other checkboxes have same structure as well.... Now what I'd like to do here is to trigger a click event to change the state of checkbox and check/uncheck it when it's clicked on it...
What I have done here via jQuery is like following:
$(document).on("click", ".ChangeCheckbox", function () {
// $('#check20').attr('checked', false);
// console.log($(this).closest("tr"));
//console.log($(this).closest("tr").find('td:eq(2)'));
$(this).closest("tr").find('td:eq(2)').attr('checked', false);
});
I'm trying to find a row which triggered the event, and then it's column #2 (eq(2)) and this is the column where the checkbox is placed...
Now the only problem here that I don't know how to solve is how do I access the input checkbox type after selected second column like following:
$(this).closest("tr").find('td:eq(2)') // how to select now the checkbox and set it's attribute to unchecked?
Can someone help me out?
Aucun commentaire:
Enregistrer un commentaire