jQuery – 获取与单击的元素在同一行中的表单元格的文本值

我单击表单元格中的链接。我需要获取在同一个表行中的特定单元格的值。
<tr>
    <td class="one">this</td>
    <td class="two">that</td>
    <td class="three">here</td>
    <td class="four"><a href="#">there</a></td>
</tr>
<tr>
    <td class="one">qwqw</td>
    <td class="two">dfgh</td>
    <td class="three">ui</td>
<td class="four"><a href="#">there</a></td>
</tr>

我有一个点击处理程序附加到第四个单元格中的链接。该点击处理程序调用一个打开模态窗口的函数。当模态中的表单提交时,我还要从链接被点击到这个模式的行传递值td class =“two”。

这里是发送模态的功能(问题区域获得正确的值为什么):

var Send = function() {
    var Name = $( '#name' ).val();
    var Something = $(this).closest('td').siblings('.two').text(); // version 1. doesn't work
    var Something = $(this).closest('tr').siblings('td.two').text(); // version 2 also doesn't work
    var Something = $(this).attr('class'); // version 3. just a test but also doesn't work
    $.ajax( {
        async: false,data: { name: Name,somedata: Something },type: 'POST',url: the url
    });        
};

问题是,我无法获得正确的值的东西。它应该是与clicked元素在同一行中的td class = two的值。

这一切都在一起的方式是。单击目标链接调用一个名为Send_Click()的方法。 Send_Click进行一些验证,然后调用Send(),但Something的值从未填充。这是因为这不是我想的是什么? Hjelp!

解决方法

你想要.children()而不是( documentation here):
$(this).closest('tr').children('td.two').text();

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...