2011-05-20 51 views
2

我希望我有道理這個,我有一個轉發器,並點擊一個按鈕,相應的div應該打開,我可以做到這一點,但它是硬編碼,但因爲它有一箇中繼器那裏將是不同的ID。這是我的轉發器;asp.net轉發器選擇ID與jquery

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

}); 

回答

0

在錨的Click事件,你可以這樣做,

click="YourFunction(<%# ((YourClass)Container.DataItem).Id %>)" 

然後處理您的功能標識。你將不得不修改這個以適應你的情況。

0

試着走走DOM。這樣的事情:

$(this).parent().parent().find('fullboxahrefReply').show() 
+0

嗨試過這個,它沒有工作,你有任何其他的建議?這是我試過的; ()。parent()。find('。fullbox')。show() $(this).parent()。parent()。find('。comment_box')。slideToggle(300 ) – pmillio 2011-05-21 15:52:50