2

What would be the best way to achieve this using jQuery, I'm trying to change the text for each cell upon row click, but I can't access the cell text in the first place (str is empty):

$("tr").bind("click", function() {
    $cells = $(this).children();
    $cells.each(function(index, cell) {
        var str = $(cell).val();
    });
});
Rafael
  • 1,099
  • 5
  • 23
  • 47

1 Answers1

1

A td does not have a value. Use .text() instead:

$("tr").bind("click", function() {
    $cells = $(this).children();
    $cells.each(function(cell) {
        var str = cell.text();
    });
});
martynas
  • 12,120
  • 3
  • 55
  • 60