Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:14:40+00:00 2026-06-11T04:14:40+00:00

I have a repeater and there is a div and button inside it. But

  • 0

I have a repeater and there is a div and button inside it.
But as you know in repeater ids are changed. Like
ctl00_ContentPlaceHolder1_rptToogle_ctl00_btnToogle
ctl00_ContentPlaceHolder1_rptToogle_ctl01_btnToogle
ctl00_ContentPlaceHolder1_rptToogle_ctl02_btnToogle

That code is working but it’s working for all. I mean when I click every div is opening.
I just want to open I selected, not all of them. How can I fix it?

<script type="text/javascript">
    $(document).ready(function () {
        $('[id*="btnToogle"]').click(function () {
            $('[id*="divToogle"]').slideToggle(100);
            return false;
        });
    });
</script>

<asp:Repeater id="rptToogle" runat="server">
    <ItemTemplate>
        <asp:Button id="btnToogle" runat="server" Text=""></asp:Button>
        <div id="divToogle" runat="server" style="display:none;">
             asdasd, asdasd, asdasd
        </div>
    </ItemTemplate>
</asp:Repeater>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:14:42+00:00Added an answer on June 11, 2026 at 4:14 am

    You are creating multiple divs with the id=”divToggle”. Technically speaking you really shouldn’t do this as it is invalid markup to have the different DOM elements with the same ids (although browsers will allow it).

    You can select the current button by using $(this) and then you can leverage jquery’s next() selector to get the div next to the button like this:

    <script type="text/javascript">
        $(document).ready(function () {
           $('[id*="btnToogle"]').click(function () {
                //select the very next sibling of this button, which we know is the div
                $(this).next().slideToggle(100);
                return false;
            });
        });
    </script>
    

    Please note, however, that using next() can be dangerous if you start editing your markup, because it is a relative selector, not absolute (it gets the next element, not a specific element by id).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Repeater Control and in that i have code like this <div runat=server
I have a repeater of div's that look a little bit like this: <div
I have 2 Repeaters one inside another. <div id=result> <asp:Repeater runat=server id=results> <Itemtemplate> <asp:Button
I have a repeater inside which i put a Checkbox and above rapeater there
I have a repeater that outputs divs like the following for every item returned
I have a view in which I there is a repeater control wrapped with
I have a repeater control that contains an ItemTemplate containing a databound label and
I have a Repeater control that is being bound to the result of a
I have a repeater like this: <asp:Repeater runat=server ID=pde> <HeaderTemplate></HeaderTemplate> <ItemTemplate> <asp:Literal runat=server ID=literal1></asp:Literal>
I have an (unordered)list (generated by a repeater) of items. However, I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.