jquery - how to set a table cell to a value when next sibling td's checkbox is checked -
this code:
... <td class="paymentstatus">@model.paymentstatus</td> <td><input type="checkbox" class="checkbox"/></td> </tr>
what i'm wanting when checkbox checked set paymentstatus td text "payment checked"
i tried this:
$(".checkbox").change(function () { if ($(this).is(":checked")) { $(this).closest('.paymentstatus').text("payment checked"); } });
doesn't work. know why , how fix?
you need use closest
parent td
, sibling(td.paymentstatus)
set text.
demo
$(".checkbox").change(function () { if ($(this).is(":checked")) { $(this).closest('td') .siblings('td.paymentstatus') .text("payment checked"); } });
Comments
Post a Comment