Ralph
Ralph

Reputation: 897

Trouble selecting table tds

I'm trying to change two table cell(td) values based on if one of the tds has a checkbox that is selected. I'm trying to change the 3rd and 4th tds in the table row. I can change the td that contains the checkbox, I just can't change the text of the td to the left of it.

Js

 //this event is triggered after a form submit
 $('#frm input:checkbox:checked').each(function () {

      // change 4th column text - this works
      $(this).closest('td').html("test");

      // change 3rd column text - can't seem to select this td
      $(this).closest('td').parent('tr').eq(2).html("test");  
 });

Upvotes: 1

Views: 36

Answers (1)

NRaf
NRaf

Reputation: 7559

If $(this).closest('td') gives you the 4th td, $(this).closest('td').prev() should give you the third.

Upvotes: 1

Related Questions