i need contents of cells in row, combine them, , put them textarea. think need .each() function, like:
$('table tr').each(function() { $(this).find('td').text().appendto(textarea); // not right });
but don't know how combine contents of each cell 1 , put textarea.
basically, have table this:
<table> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> </table>
and want end this:
<textarea> 1,2,3,4 1,2,3,4 1,2,3,4 </textarea>
http://jsfiddle.net/qy1e7to6/33/
i appreciate can give. thank you.
you're close! each iteration of table row
, want combine sequence of characters each cell ,
separator. @ end, want line break
.
one way can combine text ,
separator using array , joining array
var chars = []; // add characters here... chars.join(',');
when append, can add new line text:
var chars = []; // iterate each cell , push array join later! $(this).find('td').each(function(){ chars.push($(this).text()); }); // append text area , join array textarea.append(chars.join(','), '\n');
here's updated fiddle: http://jsfiddle.net/qy1e7to6/34/