Reputation: 1223
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();
});
});
Upvotes: 2
Views: 3438
Reputation: 12290
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();
});
});
Upvotes: 1