I am very new to jQuery, so apologies for what might be a very simple question.
I have a table, and when I click on the row, I want the details of the cells to be filled into the form:
such a simple example
<table id="table">
<tr><td class="field1">1 </td><td class="field2">2 </td></tr>
</table>
<input id="input" type="text" />
So jQuery:
$(document).ready(function() {
$('#table tr').click(function() {
$test = $(this).find('td').context.innerText)
$('#input').val( );
})
- returns the inner text tr (ie "1 2"
How can i do this...
Thanks in advance
Andy
Edit: ok in my fever, I see that I messed up what I wanted to type, here is js, I try:
$(document).ready(function() {
$('#table tr').click(function() {
$field1 = $(this).find('td.field1').context.innerText)
$('#input1').val($field1);
$field2 = $(this).find('td.field2').context.innerText)
$('#input12').val($field2);
})
Confusion Applications
source
share