(Jquery) Find the contents of a td from a selected tr

Posted by Andy on Stack Overflow See other posts from Stack Overflow or by Andy
Published on 2010-03-08T12:08:12Z Indexed on 2010/03/08 12:21 UTC
Read the original article Hit count: 214

Filed under:
|
|
|

I am very new to JQuery, so appologies for what may be a very simple question.

I have a table, and when i click on a row, i want the cells details to be filled into a form:

so simple example

<table id="table">
 <tr><td class="field1">1 </td><td class="field2">2 </td></tr>
</table>
<input id="input" type="text" />

So the JQuery:

$(document).ready(function() {
   $('#table tr').click(function() {
       $test = $(this).find('td').context.innerText) //problem here *
       $('#input').val( );
   })
  • this returns the innertext of the tr (i.e "1 2"

How am i supose to do it...

Thanks in advance

Andy

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html