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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -