0

このテキスト ボックスから gridView 要素を変更するだけです。

<asp:TextBox runat="server" ID="curDate"></asp:TextBox>

以下のこのラベルに:

<asp:Label ID="curDate" runat="server"></asp:Label>

以下のjQueryはテキストボックスでうまく機能しますが、上のラベルを機能させるにはどうすれば変更できますか?

<script type="text/javascript"> 

    function CheckBox_Click() { 
        $('#' + '<%=gridView1.ClientID %>' + ' tr:has(:checkbox:checked)  td:nth-child(5) input:text').each(function () { 
            $(this).attr("value",new Date()); 
        }); 

    } 

    </script>

前もって感謝します

4

2 に答える 2

0
$('#' + '<%=gridView1.ClientID %>' + ' tr:has(:checkbox:checked)  td:nth-child(5) label').each(function () { 
        $(this).text(new Date()); 
    }); 
于 2012-08-26T15:17:45.577 に答える
0

このようにしてみてください(私はasp.net開発者ではありませんが、ほとんどの場合コードを操作しています):

<asp:Label ID="curDate" runat="server" CssClass="theLabel"></asp:Label>

あなたのjqueryは次のようになります:

$('#' + '<%=gridView1.ClientID %>' + ' tr:has(:checkbox:checked) .theLabel').each(function () { 
        $(this).text(new Date()); 
    }); 

同じアイデアを使用して、「一意の」CssClass を gridView パネルに設定することもできます (パネルですか?)。これは新しいセレクター (つまりCssClass="theGrid") になり、jquery を次のように変更します。

$('.theGrid tr:has(:checkbox:checked) .theLabel').each(function () { 
        $(this).text(new Date()); 
    });
于 2012-08-26T23:21:46.867 に答える