使用JQuery获取表值

使用JQuery获取表值,jquery,Jquery,我有一个包含4个表格单元格的html表格: 1:复选框 2.标签 3.文本框 4.标签 单击复选框后,会触发jquery函数,但我正在尝试获取复选框旁边的值。我在下面试过了,但没有效果。我知道我很接近。任何帮助都将不胜感激 $(this).next() $(this).nextSibling $(this).nextSibling.childNodes[0] <table id="MainContent_cockpitTable" style="width:80%;"> &

我有一个包含4个表格单元格的html表格: 1:复选框 2.标签 3.文本框 4.标签

单击复选框后,会触发jquery函数,但我正在尝试获取复选框旁边的值。我在下面试过了,但没有效果。我知道我很接近。任何帮助都将不胜感激

$(this).next()
$(this).nextSibling
$(this).nextSibling.childNodes[0]


 <table id="MainContent_cockpitTable" style="width:80%;">
  <tr>
<td>
      <input id="MainContent_check_FLIGHT DECK1" type="checkbox" checked="checked"/>    
    </td>
     <td>Pilot</td>
     <td><input "type="text" value="86.2" maxlength="10" id="MainContent_input_FLIGHT DECK_weight1" />
     </td>
     <td><span id="MainContent_input_FLIGHT DECK_arm1" style="display:inline-block;width:50px;">255.0</span></td>
</tr>
 </table>
$(this).next()
$(此).nextSibling
$(this.nextSibling.childNodes[0]
领航员

这应该有用——(我想)你有这样的东西

<table>
  <tr>
    <td> <input type=checkbox .... /> </td>
    <td> YOU WANT THIS LABEL </td>
    <td> <input type=textbox ..... /> </td>
    <td> ANOTHER LABEL </td>
  </tr>
</table>

你想要这个标签吗
另一个标签

工作演示

您的具体案例演示

请注意:
类可以有空格,但不能有
id
id
应该是唯一的

希望它适合你的事业
:)

代码

$('.hulk').click(function(e) {
    alert($(this).parents('tr').html());
     alert('Lable HTML = > ' + $(this).parents('tr').find('lable').text())   
});
​
进一步

$('.hulk').click(function() {
    alert($(this).parents('tr').html());
    alert('Pilot here:=> ' + $(this).parent().next().html());
    alert('Lable HTML = > ' + $(this).parents('tr').find('span').text())
});​

你能发布你的html代码吗?可能更容易理解。复选框旁边的值?我的答案会起作用-我猜到了你的html,并且猜对了。当复选框被选中时,你是否试图获取文本输入的值?我只是猜,当他说标签时,他指的是纯文本,我想你和其他一些人认为他知道他说的是什么,为什么不+1,今天没有人提高投票率
:)
为什么不+1,今天没有人提高投票率
:)
<table>
  <tr>
    <td> <input type=checkbox .... /> </td>
    <td> YOU WANT THIS LABEL </td>
    <td> <input type=textbox ..... /> </td>
    <td> ANOTHER LABEL </td>
  </tr>
</table>
$('.hulk').click(function(e) {
    alert($(this).parents('tr').html());
     alert('Lable HTML = > ' + $(this).parents('tr').find('lable').text())   
});
​
$('.hulk').click(function() {
    alert($(this).parents('tr').html());
    alert('Pilot here:=> ' + $(this).parent().next().html());
    alert('Lable HTML = > ' + $(this).parents('tr').find('span').text())
});​