我對JQuery非常陌生,所以對於可能是一個非常簡單的問題的appologies。(jquery)從選定的tr中查找td的內容
我有一個表,當我在一排點擊,我想單元的詳細信息填充到一個形式:
這麼簡單的例子
<table id="table">
<tr><td class="field1">1 </td><td class="field2">2 </td></tr>
</table>
<input id="input" type="text" />
所以JQuery的:
$(document).ready(function() {
$('#table tr').click(function() {
$test = $(this).find('td').context.innerText) //problem here *
$('#input').val();
})
- 此返回TR將InnerText(即 「1 2」
我怎樣supose做...
在此先感謝
安迪
編輯:好吧,我搶我知道我搞砸了我的supose打字,這裏是JS我試圖:
$(document).ready(function() {
$('#table tr').click(function() {
$field1 = $(this).find('td.field1').context.innerText) //problem here *
$('#input1').val($field1);
$field2 = $(this).find('td.field2').context.innerText) //problem here *
$('#input12').val($field2);
})
Appologies的混亂
我不知道如果我的編輯所做的任何更改您的建議,如果你可以去看看。並感謝您的回覆,我會看看 – Andy 2010-03-08 12:30:15
噢好神,那很容易,謝謝你的工作/ bonk – Andy 2010-03-08 12:32:20