Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 查找与当前元素相关的文本框_Javascript_Jquery_Html_Html Table - Fatal编程技术网

Javascript 查找与当前元素相关的文本框

Javascript 查找与当前元素相关的文本框,javascript,jquery,html,html-table,Javascript,Jquery,Html,Html Table,这是我的HTML: <tr> <td colspan="2" class="borderBottomCell"> <div class="benefitInfo" style="WIDTH: 99%! important;"> <asp:DropDownList runat="server" ID="

这是我的HTML:

<tr>
                        <td colspan="2" class="borderBottomCell">
                          <div class="benefitInfo" style="WIDTH: 99%! important;">
                            <asp:DropDownList runat="server" ID="ddlbc1"  />
                            <asp:Label runat="server" ID="lblbc1" />
                            <asp:Literal runat="server" ID="spcbc1" Text="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />
                            <asp:Label runat="server" ID="bd1" />
                            <asp:HiddenField runat="server" ID="hdnbc1"  /> 
                          </div>
                        </td>
                        <td class="borderBottomCell2">
                            <asp:TextBox runat="server" ID="amt1" CssClass="transparentTextBox amount" Width="60px" Columns="9" />
                        </td>
                        <td class="borderBottomCell2">
                            <asp:TextBox runat="server" ID="int1" CssClass="transparentTextBox" Width="60px" Columns="9" />

                        </td>
                    </tr>
实现这一目标的最佳方式是什么?我应该获得对
parent().parent().next().find(“:input”)
的引用吗。。。或者类似的东西?

这应该可以:

$(".benefitInfo select").each(function() {
    var ddl = $(this);
    var amtTxt = ddl.closest('tr').find('.amount');
});

我会提出一个额外的建议,并用和元素类型限定CSS类,即
div.benefitInfo
input.amount
$(".benefitInfo select").each(function() {
    var ddl = $(this);
    var amtTxt = ddl.closest('tr').find('.amount');
});