Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.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
切换使用Repeater控件ASP.NET创建的行_Asp.net_Jquery - Fatal编程技术网

切换使用Repeater控件ASP.NET创建的行

切换使用Repeater控件ASP.NET创建的行,asp.net,jquery,Asp.net,Jquery,我正在使用Repeater控件创建数据列表。某些行可能有其他行,应使用主行的可单击图像进行切换。 这里是HTML部分 <table cellpadding="2" cellspacing="0" width="100%"> <asp:Repeater ID="repeatLockers" runat="Server"> <HeaderTemplate>

我正在使用Repeater控件创建数据列表。某些行可能有其他行,应使用主行的可单击图像进行切换。

这里是HTML部分

<table cellpadding="2" cellspacing="0" width="100%">
                <asp:Repeater ID="repeatLockers" runat="Server">
                    <HeaderTemplate>
                        <tr>
            <td>&nbsp;</td>
                            <td>A</td>
                        </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr id="trItem" class="SomeParentClass" runat="server">
                            <td>
                                <img id="imgToggleHomeInfo" runat="server" alt="show/hide repetitves" src="icon_plus.gif"
                                    style="cursor: pointer" />
                            </td>
                            <td>
                                <asp:Label ID="lbl" runat="server"></asp:Label>
                            </td>
                        </tr>
                        <tr id="trAddOnFee" runat="server" class="SomeClass" style="display: none;">
                            <td colspan="2">
                                <table cellpadding="4" cellspacing="2" width="100%">
                                    <tr>
                                        <td class="DgHeader">A</td>
                                        <td class="DgHeader">B</td>
                                    </tr>
                                    <asp:Repeater ID="repeatRepetitives" runat="server">
                                        <ItemTemplate>
                                            <tr>
                                                <td>
                                                    <asp:Label ID="lblA" runat="server"></asp:Label>
                                                </td>
                                                <td align="right"> 
                                                    <asp:Label ID="lblB" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </table>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </table>

A.
A.
B

如何使用Jquery在其父行上单击imgToggleHomeInfo“image”来切换类为“SomeClass”的行?

我会找到映像的父行,然后切换它的下一个同级

$(document).ready( function() {
    $("[id$='imageToggleHomeInfo']").click( function() {
        $(this).closest('tr').next().toggle();
    });
})

$(this).parent('tr').next().toggle();不起作用。但这正在起作用:$(this).parent().parent().next().toggle();parent必须只搜索直接的父项。parent().parent()可以,但您可以使用parents()方法查看元素的所有祖先。这将取决于此表未包含在另一个表中。如果是,您可能需要使用“tr:last”。+1-如果您可以将此更新为使用
。最近('tr')
,我知道在回答时它不可用,但它对未来的谷歌用户有用:)