开发者

asp.net repeater select ID with Jquery

I hope i make sense this, i have a repeater and on click of a button, the corresponding div should open up, I can do this when it is hardcoded however since its a repeater there will be different IDs. Here is my repeater;

<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>
        开发者_StackOverflow中文版    <div id="fullbox" class="fullboxahrefReply"></div>
            <div id="commentload"></div>
        </li>
    </ItemTemplate>
</asp:Repeater>

Here is the jquery which i am trying to get to call it, it works now however when i start changing the ID's i will have a problem, how do i solve this;

//Comment Box Slide
$("[id$=ahrefReply]").live("click", function () 
{

    var ID = $(this).attr("id");
    $(".fullbox" + "ahrefReply").show();
    $("#c" + "ahrefReply").slideToggle(300);

});


In the anchor's click event, you can do something like,

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

Then handle the id in your function. You will have to modify this to work with your situation as well.


Try just walking up the DOM. Something like this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜