2012-08-26 48 views
0

我們只是改變我們的GridView元素從這個文本框:如何更改JQuery以使用標籤而不是文本框?

<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> 

在此先感謝

回答

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()); 
    }); 

使用相同的想法,你可以s等人的「獨一無二」的CssClass以及您的GridView控件面板(是面板?) 所以這將是新的選擇(即CssClass="theGrid"),改變了jQuery如下:

$('.theGrid tr:has(:checkbox:checked) .theLabel').each(function() { 
     $(this).text(new Date()); 
    }); 
+0

對於遲到的迴應抱歉。 不幸的是,您提出的這些解決方案都沒有奏效。 – Kenny

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

感謝@ bondythegreat,那是什麼我之前嘗試過,我又試了一次。它沒有給出錯誤,但它沒有按照它應該插入的日期。 – Kenny

+0

可以請你發佈生成的html嗎? – bondythegreat

+0

這裏是一條線。所有的人都以同樣的方式: ​​ Kenny

相關問題