I have a simple table (larger than this example)
<table cellpadding="0" cellspacing="0" id="chess_board">
<tbody>
<tr>
<td id="A8"><a class="rook black" href="#"></a></td>
<td id="B8"><a class="knight black" href="#">Cont1</a></td>
<td id="C8"><a class="bishop black" href="#">Cont2</a></td>
</tr>
<tr>
<td id="A7"><a class="pawn black" href="#">Cont3</a></td>
<td id="B7"><a class="pawn black" href="#"></a></td>
<td id="C7"><a class="pawn black" href="#">Cont4</a></td>
</tr>
</tbody>
</table>
In jquery, how do i loop through all td and return a string containg not empty td id and text? In this case a string
"B8 Cont1 C8 Cont2 A7 Cont3 C7 Cont4"
I know the existence of the 'each' function but it's a callback and i can't build my string during the loop (do i?).