[英]asp.net repeater select ID with Jquery
我希望我有道理,我有一個中繼器,單擊一個按鈕,相應的div應該打開,當它被硬編碼時,我可以這樣做,但是由於其中繼器將有不同的ID。 這是我的中繼器;
<asp:Repeater ID="rptProfileStatus" OnItemDataBound="rptProfileStatus_OnItemDataBound"
runat="server">
<ItemTemplate>
<li class="bar1">
<a name="jh"></a>
<div align="left" class="post_box">
<div class="itembottom">
<span class="date">
<asp:Label ID="lblDate" Font-Underline="false"
ForeColor="white" runat="server"></asp:Label>
</span>
<span class='feed_link'>
<a href="#" runat="server" class="comment" id="ahrefReply"></a>
</span>
<span class="commentsno">
<a href="#" class="commentsnr" id="2">2 comments</a>
</span>
</div>
<span class="delete_button">
<a href="#" id="A2" class="delete_update"></a>
</span>
</div>
<div id="fullbox" class="fullboxahrefReply"></div>
<div id="commentload"></div>
</li>
</ItemTemplate>
</asp:Repeater>
這是我試圖調用它的jQuery,它現在可以正常工作,但是當我開始更改ID時,我將遇到問題,我該如何解決?
//Comment Box Slide
$("[id$=ahrefReply]").live("click", function ()
{
var ID = $(this).attr("id");
$(".fullbox" + "ahrefReply").show();
$("#c" + "ahrefReply").slideToggle(300);
});
在錨點的click事件中,您可以執行以下操作:
click="YourFunction(<%# ((YourClass)Container.DataItem).Id %>)"
然后在您的函數中處理id。 您還必須修改此設置以適合您的情況。
嘗試僅沿DOM走。 像這樣:
$(this).parent().parent().find('fullboxahrefReply').show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.